

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Tiled 1.4.2 documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script type="text/javascript" src="_static/jquery.js"></script>
        <script type="text/javascript" src="_static/underscore.js"></script>
        <script type="text/javascript" src="_static/doctools.js"></script>
        <script type="text/javascript" src="_static/language_data.js"></script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" type="text/css" />
  <link rel="stylesheet" href="_static/_static/css/theme.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
            
              <!-- Local TOC -->
              <div class="local-toc"><p class="caption"><span class="caption-text">User Manual</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/introduction">介绍</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#about-tiled">关于Tiled</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#getting-started">开始使用</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/projects">项目</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#what-s-in-a-project">什么是项目</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#sessions">会话</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#opening-a-file-in-the-project">在项目中打开文件</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/layers">使用图层</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#layer-types">图层类型</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tinting-layers">染色图层</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/editing-tile-layers">编辑图块图层</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#stamp-brush">图章刷</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#terrain-brush">地形刷</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#wang-brush">王氏刷子</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#bucket-fill-tool">填充工具</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#shape-fill-tool">填充形状工具</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#eraser">橡皮擦</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#selection-tools">选择工具</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#managing-tile-stamps">管理图块刷</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/objects">使用对象</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#placement-tools">放置工具</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#select-objects">选择对象</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#edit-polygons">编辑多边形</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#connecting-objects">连接对象</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/editing-tilesets">编辑图块集</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#two-types-of-tileset">两种类型的图块集</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tileset-properties">图块集属性</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tile-properties">图块集</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#terrain-information">地形信息</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#wang-sets">王氏集合</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tile-collision-editor">图块碰撞体编辑器</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tile-animation-editor">图块动画编辑器</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/custom-properties">自定义属性</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#adding-properties">添加属性</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tile-property-inheritance">继承图块属性</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#predefining-properties">预定义属性</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/using-templates">使用模板</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#creating-templates">创建模板</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#creating-template-instances">创建模板实例</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#editing-templates">编辑模板</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#detaching-template-instances">拆分模板实例</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/using-the-terrain-tool">使用地形刷</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#create-a-new-map-and-add-a-tileset">创建一个新的地图并添加图块集</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#define-the-terrain-information">定义地形信息</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#editing-with-the-terrain-brush">使用地形刷编辑</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#final-words">结束语</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/using-wang-tiles">使用王氏图块</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#defining-wang-tile-info">定义王氏图块信息</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#editing-with-wang-methods">使用王氏方法编辑</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#customizing-wang-colors">自定义王氏颜色</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#standard-wang-sets">标准王氏图集</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/using-infinite-maps">使用无限地图</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#creating-an-infinite-map">创建一个无限地图</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#editing-the-infinite-map">编辑无限地图</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#conversion-from-infinite-to-finite-map-and-vice-versa">无限地图、有限地图的相互转换</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/worlds">与世界配合工作</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#defining-a-world">定义一个世界</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#editing-worlds">编辑世界</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#using-pattern-matching">使用模式匹配</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#showing-only-direct-neighbors">只显示直系邻居</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/using-commands">使用命令</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#the-command-button">命令按钮</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#editing-commands">编辑命令</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#example-commands">示例命令</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/automapping">自动映射</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#what-is-automapping">什么是自动映射？</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#setting-it-up">设置它</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#examples">示例</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/export">Export Formats</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#json">JSON</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#lua">Lua</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#csv">CSV</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#gamemaker-studio-1-4">GameMaker: Studio 1.4</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tbin">tBIN</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#defold">Defold</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#other-formats">Other Formats</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#export-as-image">Export as Image</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/keyboard-shortcuts">Keyboard Shortcuts</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#general">General</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#when-a-tile-layer-is-selected">When a tile layer is selected</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#when-an-object-layer-is-selected">When an object layer is selected</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#in-the-properties-dialog">In the Properties dialog</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/preferences">User Preferences</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#general">General</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#interface">Interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#keyboard">Keyboard</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#theme">Theme</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#plugins">Plugins</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-manual/python">Python Scripts</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#example-export-plugin">Example Export Plugin</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#debugging-your-script">Debugging Your Script</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#api-reference">API Reference</a></li>
</ul>
</li>
</ul>
<p class="caption"><span class="caption-text">Reference</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-reference/support-for-tmx-maps">Libraries and Frameworks</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#support-by-language">Support by Language</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#support-by-framework">Support by Framework</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-reference/tmx-map-format">TMX Map Format</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#map">&lt;map&gt;</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#editorsettings">&lt;editorsettings&gt;</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tileset">&lt;tileset&gt;</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#layer">&lt;layer&gt;</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#objectgroup">&lt;objectgroup&gt;</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#imagelayer">&lt;imagelayer&gt;</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#group">&lt;group&gt;</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#properties">&lt;properties&gt;</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#template-files">Template Files</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-reference/tmx-changelog">TMX Changelog</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-1-4">Tiled 1.4</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-1-3">Tiled 1.3</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-1-2-1">Tiled 1.2.1</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-1-2">Tiled 1.2</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-1-1">Tiled 1.1</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-1-0">Tiled 1.0</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-0-18">Tiled 0.18</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-0-17">Tiled 0.17</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-0-16">Tiled 0.16</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-0-15">Tiled 0.15</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-0-14">Tiled 0.14</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-0-13">Tiled 0.13</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-0-12">Tiled 0.12</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-0-11">Tiled 0.11</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-0-10">Tiled 0.10</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-0-9">Tiled 0.9</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tiled-0-8">Tiled 0.8</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-reference/json-map-format">JSON Map Format</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#map">Map</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#layer">Layer</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#chunk">Chunk</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#object">Object</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#text">Text</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#tileset">Tileset</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#object-template">Object Template</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#property">Property</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#point">Point</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#changelog">Changelog</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-reference/scripting">Scripting</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#introduction">Introduction</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#api-reference">API Reference</a></li>
</ul>
</li>
</ul>
</div>
            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        <!-- OVERRIDE: wy-side-nav-search moved out of wy-side-scroll -->
        <div class="wy-side-nav-search" >
          
            <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          

          

          
            <a href="index.html#document-index" class="icon icon-home"> Tiled
          

          
          </a>

          
            
            
            
              <span class="version">
                latest
              </span>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>
      </nav>

      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html#document-index">Docs</a> &raquo;</li>
        
      <li>Tiled 1.4.2 documentation</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            
              <a href="https://github.com/bjorn/tiled/blob/master/docs/index.rst" class="fa fa-github"> Edit on GitHub</a>
            
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="tiled-documentation">
<h1>Tiled Documentation<a class="headerlink" href="#tiled-documentation" title="Permalink to this headline">¶</a></h1>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you’re not finding what you’re looking for in these pages, please don’t
hesitate to ask questions on the <a class="reference external" href="http://discourse.mapeditor.org">Tiled Forum</a>.</p>
</div>
<div class="toctree-wrapper compound">
<span id="document-manual/introduction"></span><div class="section" id="introduction">
<h2>介绍<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<div class="section" id="about-tiled">
<h3>关于Tiled<a class="headerlink" href="#about-tiled" title="Permalink to this headline">¶</a></h3>
<p><strong>  Tiled是一款2D关卡编辑器，可以帮助你开发游戏内容。它的主要功能是编辑各种形式的平铺地图，但它
  也支持放置任意图像，以及用游戏使用的额外信息注解你的关卡的强大方式。Tiled专注于灵活性的同时努力保持直观。</strong></p>
<p>在图块地图（tile maps）方面, 它支持矩形图块层，但也支持投影等距四边形、交错等距四边形和交错六
  边形层。一个图块集(Tileset)可以是包含许多块的单个图像，也可以是单个图像的集合。为了支持一定的伪深度技
  术， 图块和层可以被偏移自定义距离和他们的渲染顺序可以配置。</p>
<p>编辑<a class="reference internal" href="index.html#tile-layer-introduction"><span class="std std-ref">图块层（Tile layers）</span></a>的工具
是图章笔刷（stamp brush），他可以有效地绘制和复制图块区域。
 它还支持绘制直线和圆。此外，还有几个选择工具和一个<a class="reference internal" href="index.html#document-manual/using-the-terrain-tool"><span class="doc">自动地形过渡（automatic terrain transitions）</span></a>工具
最后，它可以应用基于<a class="reference internal" href="index.html#document-manual/automapping"><span class="doc">模式匹配（pattern-matching）</span></a>
来自动化你的部分工作。</p>
<p>Tiled也提供<a class="reference internal" href="index.html#object-layer-introduction"><span class="std std-ref">对象图层（object layers）</span></a>,
传统上，它们只用于注释地图上的信息，但是最近它们可以用来放置图像。
你可以添加矩形、点、椭圆、多边形、多段线和图块对象（Tile Object）。
对象（Object）放置不受限与图块网格（Tile Grid），对象（Object）也可以缩放或旋转。 
对象图层（Object layers ）提供了很大的灵活性，可以将几乎任何你游戏需要的信息添加到你的关卡中。</p>
<p>另外值得一提的是支持通过插件添加自定义地图（Custom Map）或者图块集(Tileset)格式（Tileset Formats）、
  用JavaScript<a class="reference internal" href="index.html#document-reference/scripting"><span class="doc">扩展Tiled（extending Tiled）</span></a>、
  图块图章内存（the tile stamp memory）
 <a class="reference internal" href="index.html#tile-animation-editor"><span class="std std-ref">图块动画支持（tile animation support）</span></a> 和 <a class="reference internal" href="index.html#tile-collision-editor"><span class="std std-ref">图块碰撞编辑器（tile collision editor）</span></a>。</p>
</div>
<div class="section" id="getting-started">
<span id="id1"></span><h3>开始使用<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h3>
<div class="new">New in Tiled 1.4</div><div class="section" id="setting-up-a-new-project">
<h4>启动一个新项目<a class="headerlink" href="#setting-up-a-new-project" title="Permalink to this headline">¶</a></h4>
<p>当第一次启动Tiled时，我们会看到以下窗口： </p>
<div class="figure" id="id2">
<img alt="Tiled Window" src="_images/tiled-window.png" />
<p class="caption"><span class="caption-text">Tiled窗口</span></p>
</div>
<p>为了使我们的所有资产（assets）都能从 <span class="guilabel">项目</span> 视图轻松访问,
  以及能够在多个项目之间快速切换， 建议首先设置一个图块项目。但是，这是一个完全可选的步骤，可以在需要时跳过。</p>
<p>选择<em>项目 -&gt; 保存项目为…</em> 来保存一个新的项目文件。建议的位置是项目的根目录，但您可以将其放置在任何您想要的位置。 </p>
<p>接下来，我们将至少添加一个文件夹，可以是一些“资产（Assets）”文件夹，或者是项目的根目录，但您也可以选择添加几个顶级文件夹，如“tilesets”，“maps”，“templates”等。 右键项目视图并选择 <em>添加文件夹到项目…</em>以添加相关文件</p>
</div>
<div class="section" id="creating-a-new-map">
<h4>创建一个新的地图<a class="headerlink" href="#creating-a-new-map" title="Permalink to this headline">¶</a></h4>
<p>创建新地图的步骤，选择<em>文件 -&gt; 新建 -&gt; 创建新地图…</em> (<code class="docutils literal notranslate"><span class="pre">Ctrl+N</span></code>)。将弹出以下对话框： </p>
<div class="figure" id="id3">
<a class="reference internal image-reference" href="_images/tiled-new-map.png"><img alt="New Map" src="_images/tiled-new-map.png" style="width: 348.48px; height: 366.3px;" /></a>
<p class="caption"><span class="caption-text">新地图</span></p>
</div>
<p>在这里，我们选择初始地图大小、图块大小、方向、瓦块层格式、瓦块渲染顺序（仅支持<em>正交</em>地图）以及地图是否
 <a class="reference internal" href="index.html#document-manual/using-infinite-maps"><span class="doc">无限大(infinite)</span></a>。 所有这些事情都可以在以后根据需要进行更改，所以第一次就把它做好并不重要。</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">如果你创建一个项目，请确保将地图保存到已添加到项目中的文件夹中。 这将使它可以使用<em>文件 -&gt;
在项目中打开文件</em> (<code class="docutils literal notranslate"><span class="pre">Ctrl+P</span></code>).</p>
</div>
<p>保存我们的地图之后，我们将看到图块格子和一个将被添加到地图的初始瓦块层。然而，在我们能够开始使用任何图块之前，我们需要添加一个图块集(tileset)。
选择<em>文件 -&gt; 新建 -&gt; 新的图块…</em>来打开“新图块集”对话框</p>
<div class="figure" id="id4">
<a class="reference internal image-reference" href="_images/tiled-new-tileset.png"><img alt="New Tileset" src="_images/tiled-new-tileset.png" style="width: 357.72px; height: 320.1px;" /></a>
<p class="caption"><span class="caption-text">新图块集</span></p>
</div>
<p>点击<span class="guilabel">浏览…</span>按钮并选择来自Tiled例子的<code class="file docutils literal notranslate"><span class="pre">tmw_desert_spacing.png</span></code>
图块集 (如果你愿意，也可以使用你自己的)。 这个示例图块集使用一个图块大小为32x32。它在图块周围还有一个像素的<em>边距</em>和在瓦块之间有一个像素的<em>间距</em>（实际上这是非常罕见的，通常您应该将这些值保留为0）。
</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">我们将禁用 <span class="guilabel">嵌入地图</span> 设置。建议这样做，因为它允许多个地图使用这个图块集，而无需再次设置其参数。
  如果以后添加图块属性、地形定义、碰撞形状等，则最好将图块集存储在自己的文件中，因为这些信息随后会在所有地图之间共享。
</p>
</div>
<p>保存图块集之后，Tiled应该是如下这样：</p>
<div class="figure" id="id5">
<img alt="Tileset Created" src="_images/tiled-new-tileset-created.png" />
<p class="caption"><span class="caption-text">图块集创建后</span></p>
</div>
<p>由于我们现在不想对图块集执行任何其他操作，只需切换回地图文件：</p>
<div class="figure" id="id6">
<img alt="Tileset Usable on the Map" src="_images/tiled-new-map-tileset-added.png" />
<p class="caption"><span class="caption-text">Tileset Usable on the Map</span></p>
</div>
<p>我们准备选择一些图块开始绘制！但是首先，我们来快速了解一下Tiled支持的<a class="reference internal" href="index.html#document-manual/layers"><span class="doc">各种图层类型</span></a>。</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">手册的大部分内容仍需编写。幸运的是，有一个非常好的<a class="reference external" href="http://www.gamefromscratch.com/post/2015/10/14/Tiled-Map-Editor-Tutorial-Series.aspx">Tiled地图编辑器教程</a>在GamesFromScratch.com中。
另外，在各种<a class="reference internal" href="index.html#document-reference/support-for-tmx-maps"><span class="doc">引擎和框架</span></a>
中常常附带一些Tiled的使用信息</p>
</div>
</div>
</div>
</div>
<span id="document-manual/projects"></span><div class="new">New in Tiled 1.4</div><div class="section" id="projects">
<h2>项目<a class="headerlink" href="#projects" title="Permalink to this headline">¶</a></h2>
<div class="section" id="what-s-in-a-project">
<h3>什么是项目<a class="headerlink" href="#what-s-in-a-project" title="Permalink to this headline">¶</a></h3>
<p>Tiled项目文件主要定义包含属于该项目的资产的文件夹列表。另外，它还为<a class="reference internal" href="#sessions"><span class="std std-ref">会话文件session file</span></a>提供了一个定位点。</p>
<p>
  除了文件夹列表之外，项目当前还具有以下属性，这些属性可以通过“项目”->“项目属性…”<em>项目 -&gt; 项目属性…</em> 对话框进行更改。</p>
<dl class="docutils">
<dt>扩展目录</dt>
<dd><p class="first">项目特定的目录，可在其中放<a class="reference internal" href="index.html#document-reference/scripting"><span class="doc">Tiled扩展</span></a>。它默认为<code class="docutils literal notranslate"><span class="pre">extensions</span></code>，因此，当你有一个名为“extensions”的目录在你的项目文件旁边时，它将被自动提取。</p>
<p class="last">除了全局扩展外，该文件夹也会被加载。</p>
</dd>
<dt>对象类型文件</dt>
<dd><p class="first">指定义对象类型的文件。确保在打开 <a class="reference internal" href="index.html#predefining-properties"><span class="std std-ref">对象类型编辑器（Object Types Editor）</span></a>之前指定此文件, 以确保定义的任何类型都保存到正确的位置。</p>
<p class="last">未指定时，对象类型定义将保存到全局位置。 </p>
</dd>
<dt>自动映射规则文件</dt>
<dd>引用一个 <a class="reference internal" href="index.html#document-manual/automapping"><span class="doc">自动映射</span></a> 规则文件应在加载此项目时用于所有地图。它会忽略有<code class="docutils literal notranslate"><span class="pre">rules.txt</span></code>文件在其中的地图。
  It is ignored for maps that have a
<code class="docutils literal notranslate"><span class="pre">rules.txt</span></code> file saved alongside them.</dd>
</dl>
</div>
<div class="section" id="sessions">
<span id="id1"></span><h3>会话Sessions<a class="headerlink" href="#sessions" title="Permalink to this headline">¶</a></h3>
<p>
  每个项目文件都有一个关联的<em>.tiled-session</em>文件，存储在它旁边。会话文件通常不应该与其他人共享，它存储您上次打开的文件、它们上次编辑状态的一部分、对话框中上次使用的参数等。
</p>
<p>切换项目时，Tiled的项目会自动切换到关联的会话，这样您就可以轻松地从中断的位置继续。未加载项目时，将使用全局会话文件。</p>
</div>
<div class="section" id="opening-a-file-in-the-project">
<h3>在项目中打开文件<a class="headerlink" href="#opening-a-file-in-the-project" title="Permalink to this headline">¶</a></h3>
<p>设置项目的另一个优点是，您可以快速打开位于项目的某个文件夹中的任何具有可识别扩展名的文件。
使用<em>文件 -&gt; 在项目中打开文件</em> (<code class="docutils literal notranslate"><span class="pre">Ctrl+P</span></code>)来打开文件过滤器，只需输入要打开的文件名。</p>
<div class="figure" id="id2">
<img alt="Open File in Project" src="_images/open-file-in-project.png" />
<p class="caption"><span class="caption-text">在项目中打开文件</span></p>
</div>
<div class="future topic">
<p class="topic-title first">将来的扩展</p>
<p>有许多方法可以使项目更强大：</p>
<ul class="simple">
<li>通过 <a class="reference internal" href="index.html#document-reference/scripting"><span class="doc">scripting API</span></a>使项目可访问。</li>
<li>允许在每个项目的基础上关闭功能，以简化UI并减少意外执行项目不支持的操作的可能性。</li>
<li>识别项目中的各种资源，以便更有效地选择图像、图块集和模板（可能会替换系统文件对话框）。</li>
</ul>
<p>
  如果你喜欢这些计划中的任何一个，请通过<a class="reference external" href="https://www.mapeditor.org/donate">赞助Tiled开发</a>帮助我更快地完成它。我得到的支持越多，我就有更多的时间来改善Tiled！</p>
</div>
</div>
</div>
<span id="document-manual/layers"></span><div class="section" id="working-with-layers">
<h2>使用图层<a class="headerlink" href="#working-with-layers" title="Permalink to this headline">¶</a></h2>
<p>
  Tiled地图支持各种类型的内容，这些内容被组织到不同的图层中。
  最普通的图层是
<a class="reference external" href="#tile-layers">图块层（Tile Layer）</a>和<a class="reference external" href="#object-layers">对象层（Object Layer）</a>。
还有一个<a class="reference external" href="#image-layers">图像层（Image Layer）</a>用于包括简单的前景或背景图形。图层的顺序决定了内容的呈现顺序。</p>
<p>
  图层可以隐藏，限制部分可见和可以锁定。图层也有一个偏移量，可以用来相互独立地定位它们，例如假深度。最后，它们的内容可以通过与自定义的<a class="reference internal" href="#tint-color"><span class="std std-ref">染色颜色</span></a>相乘来着色。</p>
<div class="figure" id="id3">
<img alt="Layers View" src="_images/lock-visibility-toggle.png" />
<p class="caption"><span class="caption-text">“眼睛”和“锁”图标分别切换层的可见性和锁定状态。 </span></p>
</div>
<p>你可以使用<a class="reference external" href="#group-layers">组图层（Group Layers）</a>将图层组织到层次结构中。
  这使得处理大量图层更为舒适。</p>
<div class="section" id="layer-types">
<h3>图层类型<a class="headerlink" href="#layer-types" title="Permalink to this headline">¶</a></h3>
<div class="section" id="tile-layers">
<span id="tile-layer-introduction"></span><h4>图块图层<a class="headerlink" href="#tile-layers" title="Permalink to this headline">¶</a></h4>
<p>图块层提供了一种有效的方法来存储由图块数据填充的大区域。数据是一个简单的图块引用数组，因此不能为每个位置存储额外的信息。
  存储的唯一额外信息是一些标志，允许图块图形垂直、水平或反对角线翻转（以支持90度增量旋转）。</p>
<p>渲染每个平铺层所需的信息存储在地图中，该贴图根据方向和其他各种特性指定分幅的位置和渲染顺序。</p>
<p>
  尽管只能引用图块，图块层也可以在你的关卡中用于定义各种非图形信息。
  碰撞信息通常可以使用一个特殊的图块集来传递，任何一种不需要自定义属性并且总是与网格对齐的对象也可以放置在图块层上。
</p>
</div>
<div class="section" id="object-layers">
<span id="object-layer-introduction"></span><h4>对象图层<a class="headerlink" href="#object-layers" title="Permalink to this headline">¶</a></h4>
<p>对象图层很有用，因为它们可以存储许多不适合图块图层的信息。对象可以自由定位、调整大小和旋转。它们也可以有单独的自定义特性。对象有很多种： </p>
<ul class="simple">
<li><strong>矩形</strong> - 用于标记自定义矩形区域</li>
<li><strong>椭圆</strong> - 用于标记自定义椭圆或圆形区域</li>
<li><strong>点</strong> - 用于标记准确位置(since Tiled 1.1)</li>
<li><strong>多边形</strong> - 用于当矩形和椭圆无法适用时 （通常是碰撞区）</li>
<li><strong>折线</strong> - 可以是要跟随的路径或要碰撞的墙</li>
<li><strong>平铺</strong> - 平铺-用于自由放置、缩放和旋转图块图形 </li>
<li><strong>文本</strong> - 用于自定义文本或注释（自平铺1.0以来）</li>
</ul>
<p>所有对象都可以命名，在这种情况下，它们的名称将显示在其上方的标签中（默认情况下仅适用于选定对象）。
还可以为对象指定一个<em>类型</em>，这很有用，因为它可以用于自定义其标签的颜色和此对象类型的可用<a class="reference internal" href="index.html#predefining-properties"><span class="std std-ref">自定义属性</span></a> 。对于图块对象，可以从<a class="reference internal" href="index.html#tile-property-inheritance"><span class="std std-ref">其图块继承类型</span></a>。
</p>
<p>对于大多数地图类型，对象以普通像素定位。
唯一的例外是等角（isometric）地图（不是等角地图（交错））。
对于等角地图，将它们的位置存储在投影坐标空间中被认为是有用的。
为此，假定等角图块表示投影的正方形，其两侧等于<em>瓦块高度</em>。
如果在等角游戏中为对象使用不同的坐标空间，则需要相应地转换这些坐标。 
</p>
<p>对象的宽度和高度也大多以像素存储。 对于等角地图，所有形状对象（矩形、点、椭圆、多边形和多段线）都投影到上述相同的坐标空间中。
这是基于这样一个假设，即这些对象通常用于在地图上标记区域。 
</p>
</div>
<div class="section" id="image-layers">
<span id="id1"></span><h4>图像图层<a class="headerlink" href="#image-layers" title="Permalink to this headline">¶</a></h4>
<p>图像层提供了一种快速包含单个图像作为地图前景或背景的方法。
  它们目前并没有那么有用，因为如果将图像添加为图块图集并将其作为 <a class="reference internal" href="index.html#insert-tile-tool"><span class="std std-ref">图块对象</span></a>放置，则可以自由缩放和旋转图像。 
</p>
<p>使用图像图层的唯一优点是避免在使用“选择对象”工具时选择/拖动图像
  但是，由于Tiled 1.1 ，这也可以通过锁定包含您希望避免与之交互的图块对象的对象层来实现。
</p>
<div class="new new-prev">Since Tiled 1.0</div></div>
<div class="section" id="group-layers">
<span id="id2"></span><h4>编组图层<a class="headerlink" href="#group-layers" title="Permalink to this headline">¶</a></h4>
<p>编组图层的工作方式类似于文件夹，可用于将层组织成层次结构。这在地图包含大量图层时非常有用。</p>
<p>
  编组图层的可见性、不透明度、偏移、锁定和<a class="reference internal" href="#tint-color"><span class="std std-ref">染色颜色</span></a>会影响所有子层。 
</p>
<p>
  使用鼠标可以轻松地将图层拖入和拖出组。“前移图层/后移图层”操作还允许将图层移入和移出组。 
 </p>
<div class="new">New in Tiled 1.4</div></div>
</div>
<div class="section" id="tinting-layers">
<span id="tint-color"></span><h3>染色图层<a class="headerlink" href="#tinting-layers" title="Permalink to this headline">¶</a></h3>
<p>
  设置层的“<em>染色颜色</em>”属性时，这会影响图像的渲染方式。
  这包括图块、图块对象和<a class="reference internal" href="#image-layers"><span class="std std-ref">图像层</span></a>的图像。
</p>
<p>
  每个像素颜色值乘以染色颜色。这样你就可以用各种方式使你的图形变暗或着色，而不需要为它设置单独的图像。
</p>
<div class="figure" id="id4">
<img alt="Tint Color Example" src="_images/tint-color.png" />
<p class="caption"><span class="caption-text">A gray tileset rendered in a different color for each layer.</span></p>
</div>
<p>
  也可以在<a class="reference internal" href="#group-layers"><span class="std std-ref">图层组</span></a>上设置染色颜色，在这种情况下，它由组中的所有层继承。
</p>
<div class="future topic">
<p class="topic-title first">Future Extensions</p>
<p>There are many ways in which the layers can be made more powerful:</p>
<ul class="simple">
<li>Ability to lock individual objects
(<a class="reference external" href="https://github.com/bjorn/tiled/issues/828">#828</a>).</li>
<li>Moving certain map-global properties to the Tile Layer
(<a class="reference external" href="https://github.com/bjorn/tiled/issues/149">#149</a>). It would be
useful if one map could accommodate layers of different tile sizes
and maybe even of different orientation.</li>
</ul>
<p>If you like any of these plans, please help me getting around to it
faster by <a class="reference external" href="https://www.mapeditor.org/donate">sponsoring Tiled development</a>. The
more support I receive the more time I can afford to spend improving
Tiled!</p>
</div>
</div>
</div>
<span id="document-manual/editing-tile-layers"></span><div class="section" id="editing-tile-layers">
<h2>编辑图块层<a class="headerlink" href="#editing-tile-layers" title="Permalink to this headline">¶</a></h2>
<p><a class="reference internal" href="index.html#tile-layer-introduction"><span class="std std-ref">图块图层</span></a>是Tiled的一个<em>图块地图编辑器</em>.

  尽管不如<a class="reference internal" href="index.html#object-layer-introduction"><span class="std std-ref">对象图</span></a>灵活，但它们提供了高效的数据存储和良好的呈现性能以及高效的内容创建。默认情况下，每个新地图都会有一个，但如果不打算使用，可以随意删除它。
</p>
<div class="section" id="stamp-brush">
<span id="stamp-tool"></span><h3>图章刷<a class="headerlink" href="#stamp-brush" title="Permalink to this headline">¶</a></h3>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">B</span></code></p>
<p>
  编辑图块层的主要工具是图章刷。它可以用来绘制单个图块，也可以用来绘制更大的“图章”，这就是它的名字来源。
  使用鼠标右键，它还可以从当前活动层快速捕获图块图章。
  图块图章通常通过在图块集视图中选择一个或多个图块来创建。
</p>
<p>图章刷有一些额外的功能：:</p>
<ul class="simple">
<li>按住<code class="docutils literal notranslate"><span class="pre">Shift</span></code>键的同时，单击任意两点以在它们之间绘制一条线。</li>
<li>
  按住<code class="docutils literal notranslate"><span class="pre">Ctrl+Shift</span></code>键的同时，单击任意两点以第一个点为中心绘制圆或椭圆。
</li>
<li>
  使用“工具选项”工具栏上的“骰子”按钮激活<em>随机模式</em>，使图章刷使用图块图章中的随机图块绘制。
  每个平铺的概率取决于它在平铺图章上出现的频率，以及在<em>图块集编辑器</em>中对每个图块设置的概率。
</li>
<li>
  使用工具栏上的“填空王氏图块集”按钮激活<em>填空王氏图块集模式</em>，以便使用王氏方法进行图章刷绘制。
  这将使相邻的图块与要放置的边和角颜色相匹配。<a class="reference internal" href="index.html#document-manual/using-wang-tiles"><span class="doc">使用王氏图块</span></a>一章对王牌作了详细的描述。 
</li>
<li>
  与<em>图块图章</em>视图结合使用时，它还可以随机放置一组预定义的图块图章。
  这比随机放置单个图块的<em>随机模式</em>更有用。
</li>
<li>
  可以分别使用<code class="docutils literal notranslate"><span class="pre">X</span></code>和<code class="docutils literal notranslate"><span class="pre">Y</span></code> 来水平/垂直翻转当前图块图章。也可以分别使用<code class="docutils literal notranslate"><span class="pre">Z</span></code>和<code class="docutils literal notranslate"><span class="pre">Shift+Z</span></code>来向左/向右旋转。也可以从“工具选项”工具栏触发这些操作。
 </li>
</ul>
</div>
<div class="section" id="terrain-brush">
<span id="terrain-tool"></span><h3>地形刷<a class="headerlink" href="#terrain-brush" title="Permalink to this headline">¶</a></h3>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">T</span></code></p>
<p>
  地形刷允许编辑基于角的特定类型的地形过渡。
  设置它需要将地形信息与图块相关联，这在<a class="reference internal" href="index.html#document-manual/using-the-terrain-tool"><span class="doc">使用地形工具</span></a>中有详细描述。
</p>
<p>
  与<a class="reference internal" href="#stamp-tool"><span class="std std-ref">图章刷</span></a>类似，可以通过按住<code class="docutils literal notranslate"><span class="pre">Shift</span></code>键来绘制线。

  按住<code class="docutils literal notranslate"><span class="pre">Ctrl</span></code>键时，编辑区域的大小将缩小为一个角（当前与绘制线结合使用时效果不佳）。
</p>
<div class="new new-prev">Since Tiled 1.0</div><p>
  按住<code class="docutils literal notranslate"><span class="pre">Alt</span></code>键时，编辑操作也会以180度旋转的方式应用。
  这在编辑战略地图时尤其有用，因为双方需要有平等的机会。
  这个修改与 <code class="docutils literal notranslate"><span class="pre">Shift</span></code>（用于绘制线）或<code class="docutils literal notranslate"><span class="pre">Ctrl</span></code>（用于减少编辑区域）结合使用效果良好。
</p>
<div class="new new-prev">Since Tiled 1.1</div></div>
<div class="section" id="wang-brush">
<span id="wang-tool"></span><h3>王氏刷子<a class="headerlink" href="#wang-brush" title="Permalink to this headline">¶</a></h3>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">G</span></code></p>
<p>
  王氏刷子的工作方式与<a class="reference internal" href="#terrain-tool"><span class="std std-ref">地形刷</span></a>非常相似，只是它使用的是王氏刷子设置。主要区别在于：
</p>
<ul class="simple">
<li>
  王氏图块支持边和角，而地形只支持角。这使得王氏图块在绘制路径或栅栏时非常有用。
</li>
<li>
  默认大小是编辑一条边/角点。按住<code class="docutils literal notranslate"><span class="pre">Ctrl</span></code>可将其展开到整个图块。
</li>
<li>
  如果无法对立即受影响的图块进行转换，则操作将中止。
</li>
</ul>
<p>
  要使用该工具，必须从王氏图块集视图中选择一种颜色。<a class="reference internal" href="index.html#document-manual/using-wang-tiles"><span class="doc">使用王氏图块</span></a>中详细介绍了王氏图块和这个工具。 
</p>
</div>
<div class="section" id="bucket-fill-tool">
<span id="id1"></span><h3>填充工具<a class="headerlink" href="#bucket-fill-tool" title="Permalink to this headline">¶</a></h3>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">F</span></code></p>
<p>
  填充工具提供了一种快速填充空白区域或以相同图块覆盖区域的方法。
  当前激活的图块图章将在填充区域中重复。它也可以与<em>随机模式</em>或<em>王氏填充模式</em>结合使用。
</p>
<p>
  按住<code class="docutils literal notranslate"><span class="pre">Shift</span></code>键时，工具将填充当前选定区域，而不管其内容如何。这对于填充以前使用了一个或多个<a class="reference external" href="#selection-tools">选择工具</a>选择的自定义区域非常有用。
</p>
<p>
  您还可以翻转和旋转当前图章，如<a class="reference internal" href="#stamp-tool"><span class="std std-ref">图章刷</span></a>所述。
</p>
<div class="new new-prev">Since Tiled 1.1</div></div>
<div class="section" id="shape-fill-tool">
<span id="id2"></span><h3>填充形状工具<a class="headerlink" href="#shape-fill-tool" title="Permalink to this headline">¶</a></h3>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">P</span></code></p>
<p>
  此工具提供了一种快速的方法，可以用特定的图块或图案填充矩形或椭圆。按住<code class="docutils literal notranslate"><span class="pre">Shift</span></code>键可精确填充正方形或圆形。
</p>
<p>
  也可以翻转和旋转当前图章，如<a class="reference internal" href="#stamp-tool"><span class="std std-ref">图章刷</span></a>所述。
</p>
</div>
<div class="section" id="eraser">
<span id="eraser-tool"></span><h3>橡皮擦<a class="headerlink" href="#eraser" title="Permalink to this headline">¶</a></h3>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">E</span></code></p>
<p>
  一个简单的橡皮擦工具。左键单击可擦除单个平铺，右键单击可用于快速擦除矩形区域。
</p>
</div>
<div class="section" id="selection-tools">
<h3>选择工具<a class="headerlink" href="#selection-tools" title="Permalink to this headline">¶</a></h3>
<p>有各种各样的平铺选择工具，它们都以类似的方式工作：</p>
<ul class="simple">
<li><strong>矩形选择</strong> 选择允许选择矩形区域
(shortcut: <code class="docutils literal notranslate"><span class="pre">R</span></code>)</li>
<li><strong>魔术棒</strong>允许选择用同一块瓷砖填充的连接区域(shortcut: <code class="docutils literal notranslate"><span class="pre">W</span></code>)</li>
<li><strong>选择相同的图块</strong> 允许在整个层中选择相同的图块 (shortcut: <code class="docutils literal notranslate"><span class="pre">S</span></code>)</li>
</ul>
<p>默认情况下，这些工具中的每一个都将替换当前选定的区域。以下修饰符可用于更改此行为：</p>
<ul class="simple">
<li>
  按住<code class="docutils literal notranslate"><span class="pre">Shift</span></code>键可使用新区域扩展当前选择
</li>
<li>按住 <code class="docutils literal notranslate"><span class="pre">Ctrl</span></code>键将从当前选择中减去新区域</li>
<li>
  按住<code class="docutils literal notranslate"><span class="pre">Ctrl</span></code>和<code class="docutils literal notranslate"><span class="pre">Shift</span></code>键可选择新区域与当前选定区域的交集
</li>
</ul>
<p>
  也可以通过单击“工具选项”工具栏中的某个工具按钮锁定到这些模式之一（添加选中项、减去选中项或插入选中项）。
</p>
</div>
<div class="section" id="managing-tile-stamps">
<h3>管理图块刷<a class="headerlink" href="#managing-tile-stamps" title="Permalink to this headline">¶</a></h3>
<p>将当前的平铺图章存储在某处以便以后再次使用，这通常很有用。以下快捷方式可用于此目的：</p>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">1-9</span></code> - 存储当前平铺图章（类似于 <code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">C</span></code>）</li>
<li><code class="docutils literal notranslate"><span class="pre">1-9</span></code> - 调用存储在该位置的图章（类似于
<code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">V</span></code>）</li>
</ul>
<p>
  图块图章还可以按名称存储，并使用<em>图块图章</em>视图进行扩展。
</p>
</div>
</div>
<span id="document-manual/objects"></span><div class="section" id="working-with-objects">
<h2>使用对象<a class="headerlink" href="#working-with-objects" title="Permalink to this headline">¶</a></h2>
<p>使用对象，你可以添加大量的信息到你的地图上，在你的游戏中使用。
  它们可以替代单调乏味的替代品，如源代码中的硬编码坐标（如生成点）或维护用于存储游戏元素的附加数据文件。</p>
<p>
  通过使用<em>图块对象</em>，可以使各种类型的对象易于识别，也可以用于纯粹的图形目的。
  在某些情况下，它们可以完全取代瓷砖层的使用，如“Sticker Knight”示例所示。
</p>
<p>
  所有对象都可以具有<a class="reference internal" href="index.html#document-manual/custom-properties"><span class="doc">自定义属性</span></a>，这些特性也可以用于创建<a class="reference internal" href="#connecting-objects"><span class="std std-ref">对象之间的连接</span></a>。
</p>
<p>
  要开始使用对象，请将<a class="reference internal" href="index.html#object-layer-introduction"><span class="std std-ref">对象图层</span></a>添加到地图中。 
</p>
<div class="section" id="placement-tools">
<h3>放置工具<a class="headerlink" href="#placement-tools" title="Permalink to this headline">¶</a></h3>
<p>每种类型的对象都有自己的放置工具。</p>
<div class="new new-prev">Since Tiled 1.2</div><p>
  当您将鼠标悬停在地图上时，将显示要放置的对象的预览。放置对象时，可以按<code class="docutils literal notranslate"><span class="pre">Escape</span></code>键或单击鼠标右键取消对象的放置。再次按<code class="docutils literal notranslate"><span class="pre">Escape</span></code>键切换到<a class="reference internal" href="#select-objects-tool"><span class="std std-ref">选择对象</span></a>工具。
</p>
<div class="section" id="insert-rectangle">
<span id="insert-rectangle-tool"></span><h4>插入矩形<a class="headerlink" href="#insert-rectangle" title="Permalink to this headline">¶</a></h4>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">R</span></code></p>
<p>
  矩形是Tiled支持的第一种类型的对象，这就是为什么在<a class="reference internal" href="index.html#document-reference/tmx-map-format"><span class="doc">TMX映射格式</span></a>中对象默认为矩形。
  它们对于标记矩形区域和为其指定自定义特性非常有用。
  它们也经常用于指定碰撞盒。
</p>
<p>
  通过在任意方向单击并拖动来放置矩形。
  按住<code class="docutils literal notranslate"><span class="pre">Shift</span></code>使其保持正方形和按住<code class="docutils literal notranslate"><span class="pre">Ctrl</span></code>可将其大小捕捉到图块大小。
</p>
<p>
  矩形对象的原点在左上角。但是，如果矩形为空（宽度和高度均为0），则它将呈现为围绕其位置的小正方形。这主要是为了保持它的可视性和可选择性。
</p>
<div class="new new-prev">Since Tiled 1.1</div></div>
<div class="section" id="insert-point">
<span id="insert-point-tool"></span><h4>插入点<a class="headerlink" href="#insert-point" title="Permalink to this headline">¶</a></h4>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">I</span></code></p>
<p>
  点是可以放置在地图上的最简单的对象。它们只代表一个位置，不能调整大小或旋转。只需单击地图即可定位点对象。
</p>
</div>
<div class="section" id="insert-ellipse">
<span id="insert-ellipse-tool"></span><h4>插入椭圆<a class="headerlink" href="#insert-ellipse" title="Permalink to this headline">¶</a></h4>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">C</span></code></p>
<p>
  椭圆的工作原理与 <a class="reference external" href="#insert-rectangle">矩形</a>相同，只是它们被渲染为椭圆。当区域或碰撞形状需要表示圆或椭圆时非常有用。
</p>
</div>
<div class="section" id="insert-polygon">
<span id="insert-polygon-tool"></span><h4>插入多边形<a class="headerlink" href="#insert-polygon" title="Permalink to this headline">¶</a></h4>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">P</span></code></p>
<p>
  多边形是定义区域形状最灵活的方式。它们最常用于定义碰撞形状。
</p>
<p>
  放置多边形时，第一次单击将确定对象的位置以及多边形的第一个点的位置。
  随后的单击用于向多边形添加其他点。
  多边形至少需要有三个点。再次单击第一个点以完成多边形的创建。可以按<code class="docutils literal notranslate"><span class="pre">Escape</span></code>键取消多边形的创建。
</p>
<p>
  如果要在放置多边形后对其进行更改，则需要使用“<a class="reference internal" href="#edit-polygons-tool"><span class="std std-ref">编辑多边形</span></a>”工具。
</p>
<div class="section" id="polylines">
<h5>折线<a class="headerlink" href="#polylines" title="Permalink to this headline">¶</a></h5>
<p>
  多段线是通过不闭合多边形来创建的。在创建多边形时单击鼠标右键或按Enter键将其作为多段线完成。
</p>
<p>
  多段线渲染为直线，只需要两个点。虽然它们可以表示碰撞墙，但它们通常也用于表示要遵循的路径。
</p>
<div class="new new-prev">Since Tiled 1.2</div><p>
  选中现有多段线后，可以通过单击显示的点在其任一端延伸现有的多段线。
  也可以通过将多段线连接到另一个现有多段线对象的任一端来完成多段线。这还需要选择另一个多段线对象，因为交互式点仅显示在选定的多段线上。
</p>
<p>
  <a class="reference internal" href="#edit-polygons-tool"><span class="std std-ref">编辑多边形</span></a>工具也用于编辑多段线。
</p>
</div>
</div>
<div class="section" id="insert-tile">
<span id="insert-tile-tool"></span><h4>插入图块<a class="headerlink" href="#insert-tile" title="Permalink to this headline">¶</a></h4>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">T</span></code></p>
<p>
  图块可以作为对象插入，以便在地图上放置、缩放和旋转图块图像时具有充分的灵活性。
  与所有对象一样，图块对象也可以具有与其关联的自定义属性。这使得它们对于放置需要特殊信息的可识别交互对象非常有用，例如具有定义内容的容器或具有定义脚本的NPC。
</p>
<p>
  要放置图块对象，请首先在<em>图块集</em> 视图中选择要放置的图块。然后在地图上使用鼠标左键开始放置对象，移动以定位对象，然后松开以完成放置对象。
</p>
<div class="new new-prev">Since Tiled 1.0</div><p>
  要更改现有图块对象，使用<a class="reference internal" href="#select-objects-tool"><span class="std std-ref">选择对象</span></a>工具选择所有你想要改变的对象，然后在<em>图块集</em>视图中右键一个图块，选择<em>替换图块</em>。
</p>
<div class="new">New in Tiled 1.4</div><p>
  可以使用<em>图块集</em>上的<em>对象对齐</em>属性自定义图块对象的对齐方式。
  出于兼容性原因，默认情况下，此属性设置为“未指定”，在这种情况下，图块对象在所有方向上都是左下对齐的，但在等距地图上，图块对象是从下居中对齐的。将此属性设置为左上角可使图块对象的对齐方式与
  <a class="reference internal" href="#insert-rectangle-tool"><span class="std std-ref">矩形对象</span></a>
  的对齐方式一致。
</p>
<div class="new new-prev">Since Tiled 1.1</div></div>
<div class="section" id="insert-template">
<span id="insert-template-tool"></span><h4>插入模板<a class="headerlink" href="#insert-template" title="Permalink to this headline">¶</a></h4>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">V</span></code></p>
<p>
  可用于快速插入“模板”视图中所选模板的多个实例。请参见
  <a class="reference internal" href="index.html#creating-template-instances"><span class="std std-ref">创建模板实例</span></a>。
</p>
</div>
<div class="section" id="insert-text">
<span id="insert-text-tool"></span><h4>插入文本<a class="headerlink" href="#insert-text" title="Permalink to this headline">¶</a></h4>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">X</span></code></p>
<p>
  文本对象可用于向地图添加任意多行文字。您可以配置各种字体属性和换行/剪切区域，使用它对快速笔记和游戏中使用的文本都很有用。
</p>
</div>
</div>
<div class="section" id="select-objects">
<span id="select-objects-tool"></span><h3>选择对象<a class="headerlink" href="#select-objects" title="Permalink to this headline">¶</a></h3>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">S</span></code></p>
<p>
  不插入新对象时，通常使用“选择对象”工具。它包含了很多功能，如下所述。
</p>
<div class="section" id="selecting-and-deselecting">
<h4>选择和取消选择<a class="headerlink" href="#selecting-and-deselecting" title="Permalink to this headline">¶</a></h4>
<p>
  可以通过单击对象或拖动矩形套索来选择对象，选择与其区域相交的任何对象。
  通过在单击的同时按住<code class="docutils literal notranslate"><span class="pre">Shift</span></code>或<code class="docutils literal notranslate"><span class="pre">Ctrl</span></code> ，可以添加单个对象添加到/从选择中删除该对象。
  按<code class="docutils literal notranslate"><span class="pre">Escape</span></code>键取消选择所有对象。
</p>
<p>
  在对象上按住并拖动时，将选择并移动此对象。
  当这阻止您开始矩形选择时，可以按住<code class="docutils literal notranslate"><span class="pre">Shift</span></code> 键强制选择矩形。
</p>
<div class="new new-prev">Since Tiled 1.0</div><p>
  默认情况下，您与最上面的对象交互。
  当需要选择另一个对象下方的对象时，请先选择较高的对象，然后按住<code class="docutils literal notranslate"><span class="pre">Alt</span></code>键，同时在同一位置单击以选择较低的对象。
  也可以在打开上下文菜单（译者注：在对象上按右键）时按住<code class="docutils literal notranslate"><span class="pre">Alt</span></code>键以获取单击位置的所有对象的列表，因此可以直接选择所需的对象。
</p>
<div class="new new-prev">Since Tiled 1.2</div><p>
  双击要编辑的多边形或多段线，可以快速切换到 <a class="reference internal" href="#edit-polygons-tool"><span class="std std-ref">编辑多边形</span></a> 工具。
</p>
</div>
<div class="section" id="moving">
<h4>移动<a class="headerlink" href="#moving" title="Permalink to this headline">¶</a></h4>
<p>
  您可以简单地拖动任何单个对象，也可以通过拖动其中任何一个来拖动已选定的对象。按住<code class="docutils literal notranslate"><span class="pre">Ctrl</span></code>键可切换到图块网格的捕捉。
</p>
<p>
  按住 <code class="docutils literal notranslate"><span class="pre">Alt</span></code>键可强制对当前选定对象执行移动操作，而不管您在地图上单击的位置。当选定的对象很小或被其他对象覆盖时，这很有用。
</p>
<p>
  也可以使用箭头键移动选定的对象。默认情况下，这会逐像素移动对象。按住<code class="docutils literal notranslate"><span class="pre">Shift</span></code>键，同时使用箭头键将对象移动一个图块距离。
</p>
</div>
<div class="section" id="resizing">
<h4>改变尺寸<a class="headerlink" href="#resizing" title="Permalink to this headline">¶</a></h4>
<p>
  可以使用调整大小控制柄调整一个或多个选定对象的大小。按住<code class="docutils literal notranslate"><span class="pre">Ctrl</span></code>键以保持对象的纵横比和/或按住<code class="docutils literal notranslate"><span class="pre">Shift</span></code>键将调整大小的原点放置在中心。
</p>
<p>
  请注意，在调整单个对象的大小时，可以只单独更改宽度和高度。当选择了多个对象时，纵横比是恒定的，因为如果不完全支持变换，就无法使其适用于旋转对象。
</p>
</div>
<div class="section" id="rotating">
<h4>旋转<a class="headerlink" href="#rotating" title="Permalink to this headline">¶</a></h4>
<p>
  若要旋转，请单击任何选定对象以将调整大小控制柄更改为旋转控制柄。旋转之前，如果需要，可以将旋转原点拖动到其他位置。按住<code class="docutils literal notranslate"><span class="pre">Shift</span></code>键以15度增量旋转（译者注：测试发现1.4.2应该是按<code class="docutils literal notranslate"><span class="pre">Ctrl</span></code>）。再次单击任何选定对象以返回调整大小模式。
</p>
<p>
  也可以按<code class="docutils literal notranslate"><span class="pre">Z</span></code>键或<code class="docutils literal notranslate"><span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">Z</span></code>组合键以90度的步长旋转选定对象。
</p>
</div>
<div class="section" id="changing-stacking-order">
<h4>更改堆叠顺序<a class="headerlink" href="#changing-stacking-order" title="Permalink to this headline">¶</a></h4>
<p>
  如果活动<a class="reference internal" href="index.html#object-layer-introduction"><span class="std std-ref">对象图层</span></a>的“绘制顺序”属性设置为“手动”（默认为自上而下），则可以使用以下键控制选定对象在其对象图层中的堆叠顺序：
</p>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">PgUp</span></code> - 提升选定对象</li>
<li><code class="docutils literal notranslate"><span class="pre">PgDown</span></code> - 降低选定对象</li>
<li><code class="docutils literal notranslate"><span class="pre">Home</span></code> - 移动对象到最前面</li>
<li><code class="docutils literal notranslate"><span class="pre">End</span></code> - 移动对象到最后面</li>
</ul>
<p>您也可以在上下文菜单中找到这些操作。当有多个对象图层时，关联菜单还包含将选定对象移动到另一个图层的操作。</p>
</div>
<div class="section" id="flipping-objects">
<h4>翻转对象<a class="headerlink" href="#flipping-objects" title="Permalink to this headline">¶</a></h4>
<p>
  可以通过按<code class="docutils literal notranslate"><span class="pre">X</span></code>键水平翻转选定对象，也可以按<code class="docutils literal notranslate"><span class="pre">Y</span></code>键垂直翻转选定对象。对于图块对象，这也会翻转其图像。
</p>
</div>
</div>
<div class="section" id="edit-polygons">
<span id="edit-polygons-tool"></span><h3>编辑多边形<a class="headerlink" href="#edit-polygons" title="Permalink to this headline">¶</a></h3>
<p>快捷键: <code class="docutils literal notranslate"><span class="pre">E</span></code></p>
<p>多边形和多段线有它们自己的编辑需要，因此由一个单独的工具覆盖，该工具允许选择并围绕它们的节点移动。
  可以同时选择和移动多个多边形的节点。
  单击线段以选择两端的节点。
  按<code class="docutils literal notranslate"><span class="pre">Escape</span></code>可以取消选择所有节点，或者返回到<a class="reference internal" href="#select-objects-tool"><span class="std std-ref">选择对象</span></a>工具
</p>
<p>
  可以通过选择节点并从上下文菜单中选择“删除节点”来删除它们。
  <code class="docutils literal notranslate"><span class="pre">Delete</span></code>键也可用于删除选定的节点，如果未选择任何节点，则可以删除选定的对象。
</p>
<p>
  选择同一多边形的多个连续节点后，可以通过从上下文菜单中选择“加入节点”将它们加入在一起。
  也可以通过选择“分割线段”在节点之间分割线段。或者，您可以简单地双击一个段，在该位置拆分它。
</p>
<p>
  在多边形中选择两个连续节点时，也可以通过在上下文菜单中选择“删除线段”来删除线段。
  这会将多边形转换为多段线，或将一个多段线对象转换为两个多段线对象。
</p>
<div class="new new-prev">Since Tiled 1.2</div><p>
  可以在任意一端延伸多段线，右键单击这些节点并选择“扩展折线”，或者切换到<a class="reference internal" href="#insert-polygon-tool"><span class="std std-ref">插入多边形</span></a>工具并单击已选定多段线的任一端。
  可以通过在这些节点上单击鼠标右键并选择“延伸多段线”，或切换到“插入多边形”工具并单击已选定多段线的任一端来延伸多段线。
</p>
<div class="new">New in Tiled 1.4</div></div>
<div class="section" id="connecting-objects">
<span id="id1"></span><h3>连接对象<a class="headerlink" href="#connecting-objects" title="Permalink to this headline">¶</a></h3>
<p>
  将一个对象与另一个对象连接起来通常是有用的，比如开关应该打开某个门或者NPC应该沿着某个路径。
  为此，请将<code class="docutils literal notranslate"><span class="pre">object</span></code>类型的自定义属性添加到源对象。
</p>
<p>确保属性值已选中，如以下屏幕截图所示：</p>
<div class="figure" id="id2">
<img alt="Object Connection Property" src="_images/object-connection.png" />
<p class="caption"><span class="caption-text">对象连接属性</span></p>
</div>
<p>然后，您可以通过以下任一方式设置连接：</p>
<ul class="simple">
<li>
  键入目标对象的ID。
 </li>
<li>
  单击带有窗口和放大镜的图标，可打开一个对话框，在该对话框中可以过滤地图上的所有对象以找到目标对象。
</li>
<li>
  单击箭头图标，然后单击地图上的对象将其设置为目标对象。
</li>
</ul>
<p>
  如上面的屏幕截图所示，对象之间的任何连接都被渲染为箭头，采用其目标对象的颜色（定义为<a class="reference internal" href="index.html#predefining-properties"><span class="std std-ref">对象类型</span></a>的一部分或对象层的颜色）。
  可以使用<em>视图 -&gt; 显示对象引用</em>切换这些箭头的显示。
</p>
<p>
  如果您想到达目标对象，但它非常远，可以通过右键单击该属性并选择<em>转到对象</em>来跳到那里。
</p>
<div class="future topic">
<p class="topic-title first">Future Extensions</p>
<p>Here are some ideas about improvements that could be made to the above
tools:</p>
<ul class="simple">
<li>Some improvements could still be made to the support for editing
polygons and polylines, like allowing to rotate and scale the
selected nodes (<a class="reference external" href="https://github.com/bjorn/tiled/issues/1487">#1487</a>).</li>
<li>The tools could put short usage instructions in the status bar,
to help new users without requiring them to carefully read the
manual (<a class="reference external" href="https://github.com/bjorn/tiled/issues/1855">#1855</a>).</li>
</ul>
<p>If you like any of these plans, please help me getting around to it
faster by <a class="reference external" href="https://www.mapeditor.org/donate">sponsoring Tiled development</a>. The
more support I receive the more time I can afford to spend improving
Tiled!</p>
</div>
</div>
</div>
<span id="document-manual/editing-tilesets"></span><div class="section" id="editing-tilesets">
<h2>编辑图块集<a class="headerlink" href="#editing-tilesets" title="Permalink to this headline">¶</a></h2>
<p>
  要编辑图块集，需要显式地打开它进行编辑。
  外部图块集可以通过 <em>文件</em>菜单打开，但是通常，当<em>图块集</em>视图中的图块集已经打开时，编辑图块集的最快方法是单击图块集下面工具栏中的<em>编辑图块集</em>编辑图块集小按钮。
</p>
<div class="section" id="two-types-of-tileset">
<h3>两种类型的图块集<a class="headerlink" href="#two-types-of-tileset" title="Permalink to this headline">¶</a></h3>
<p>
  图块集是图块的集合。图块当前支持两种类型的图块集，创建新图块集时会选择这两种类型：
</p>
<dl class="docutils">
<dt>
  基于整张图块集图片
</dt>
<dd>
  这个图块集定义了所有图块的固定大小以及这些图块剪切的图像。
  此外，它还支持图块周围的边距和图块之间的间距，
  当图像要么恰好在它们的分隔之间或周围有空间，要么让出了每个分幅的边界像素以避免颜色损失，可以使用它。
  它允许使用平铺图像，这些图像要么恰好在它们的分幅之间或周围有空间，要么挤出了每个分幅的边界像素以避免颜色流失。

  This tileset defines a fixed size for all tiles and the image from
which these tiles are supposed to be cut. In addition it supports a
margin around the tiles and a spacing between the tiles, which
allows for using tileset images that either happen to have space
between or around their tiles or those that have extruded the border
pixels of each tile to avoid color bleeding.</dd>
<dt>多图片集合</dt>
<dd>
在这种类型的图块集中，每个图块引用自己的图像文件。当图块的大小不一样，或者稍后将图块打包到纹理中时，它非常有用。
</dd>
</dl>
<p>
  不管图块集的类型是什么，都可以将大量的元信息与它及其图块相关联。
  有些信息可以在游戏中使用，比如<a class="reference internal" href="#tile-collision-editor"><span class="std std-ref">碰撞信息</span></a>和<a class="reference internal" href="#tile-animation-editor"><span class="std std-ref">动画</span></a>。其他信息主要用于某些编辑工具。
</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">
  图块集可以嵌入到地图文件中，也可以保存在外部。从Tiled1.0，默认和推荐的方法是将图块集保存到它们自己的文件中。这简化了您的工作流程，因为它确保在所有地图之间使用相同的图块集可以共享任何元信息。
</p>
</div>
</div>
<div class="section" id="tileset-properties">
<h3>图块集属性<a class="headerlink" href="#tileset-properties" title="Permalink to this headline">¶</a></h3>
<p>
  你可以使用菜单操作<em>图块集 &gt; Tile集属性</em>访问图块集属性。
</p>
<dl class="docutils">
<dt>名称</dt>
<dd>
  图块集的名称。用于在编辑地图时标识“图块集”视图中的图块集。
</dd>
</dl>
<div class="new">New in Tiled 1.4</div><dl class="docutils">
<dt>对象对齐</dt>
<dd><p class="first">
  这个对齐方式用于引用在该图块集中图块的<a class="reference internal" href="index.html#insert-tile-tool"><span class="std std-ref">图块对象</span></a>。

  这会影响相对于对象位置（原点）的图块位置，以及应用旋转的位置。
</p>
<p class="last">
  可能的值有：<em>未指定</em>（默认值）、<em>左上</em>、<em>顶部对齐</em>、<em>右上</em>、<em>左对齐</em>、<em>居中</em>、<em>右对齐</em>、<em>左下</em>、<em>底部对齐</em>和<em>右下</em>。未指定时，平铺对象对齐通常为<em>左下角</em>，但等距地图除外，它位于<em>底部对齐</em>。
</p>
</dd>
<dt>绘制偏移</dt>
<dd>
  以像素为单位的图形偏移，
  应用于任何来自该图块集的图块（作为图块层的一部分或者作为图块对象）。这对于将你的图块对齐网格非常有用。
 </dd>
<dt>背景颜色</dt>
<dd>
  平铺集的背景色，可以在默认深灰色背景不适合图块时设置。
</dd>
</dl>
<div class="new new-prev">Since Tiled 1.0</div><dl class="docutils">
<dt>方向</dt>
<dd>
  当图块集包含等距图块时，你可以将其设置为<em>等距</em>。
  该值，以及<strong>网格宽度</strong>和<strong>网格高度</strong>属性，都由在图块顶部渲染的覆盖层考虑在内。
  例如，这有助于指定<a class="reference internal" href="#terrain-information"><span class="std std-ref">地形信息</span></a>或编辑<a class="reference internal" href="#wang-sets"><span class="std std-ref">王氏集合</span></a>。它还影响<a class="reference internal" href="#tile-collision-editor"><span class="std std-ref">图块碰撞编辑器</span></a>使用的方向。
</dd>
<dt>列数</dt>
<dd>
  这是基于整张图块集图片的图块集的只读属性，但对于多图片集合图块集，您可以控制在此处显示图块集时使用的列数。
</dd>
<dt>图像</dt>
<dd>
  此属性仅适用于基于整张图块集图片的图块集。选择源字段将显示<em>编辑…</em>按钮，允许您更改与从图像中剪切图块相关的参数。
</dd>
</dl>
<p>
  当然，与Tiled中的大多数数据类型一样，您也可以将<a class="reference internal" href="index.html#document-manual/custom-properties"><span class="doc">自定义属性</span></a>与图块集相关联。
</p>
</div>
<div class="section" id="tile-properties">
<h3>图块属性<a class="headerlink" href="#tile-properties" title="Permalink to this headline">¶</a></h3>
<dl class="docutils">
<dt>ID</dt>
<dd>
  图块集中图块的ID（只读）
</dd>
</dl>
<div class="new new-prev">Since Tiled 1.0</div><dl class="docutils">
<dt>类型</dt>
<dd>
  此属性引用在
  <a class="reference internal" href="index.html#predefining-properties"><span class="std std-ref">对象类型编辑器</span></a>
  中定义的自定义类型。有关详细信息，请参阅<a class="reference internal" href="index.html#typed-tiles"><span class="std std-ref">类型化图块（Typed Tiles）</span></a>
</dd>
<dt>宽度和高度</dt>
<dd>图块的大小（只读）</dd>
<dt>可能性</dt>
<dd>
  表示从多个选项中选择此图块的相对概率。该值在 <em>随机模式</em>下和<a class="reference internal" href="index.html#terrain-tool"><span class="std std-ref">地形笔刷</span></a>中使用。
</dd>
<dt>图像</dt>
<dd>
  仅与属于多图片集合图块集的图块相关，此选项显示图块的图像文件并允许您更改它。
</dd>
</dl>
</div>
<div class="section" id="terrain-information">
<span id="id1"></span><h3>地形信息<a class="headerlink" href="#terrain-information" title="Permalink to this headline">¶</a></h3>
<p>
  地形信息可以添加到图块集以启用<a class="reference internal" href="index.html#terrain-tool"><span class="std std-ref">地形刷</span></a>的使用。请参见有关<a class="reference internal" href="index.html#define-terrain-information"><span class="std std-ref">定义地形信息</span></a>的部分。
</p>
<div class="new new-prev">Since Tiled 1.1</div></div>
<div class="section" id="wang-sets">
<span id="id2"></span><h3>王氏集合<a class="headerlink" href="#wang-sets" title="Permalink to this headline">¶</a></h3>
<p>
  图块集可以包含任意数量的王氏集合，以便与王氏笔刷一起使用。有关详细信息，请参见<a class="reference internal" href="index.html#defining-wang-tile-info"><span class="std std-ref">定义王氏图块信息</span></a>。
</p>
</div>
<div class="section" id="tile-collision-editor">
<span id="id3"></span><h3>图块碰撞编辑器<a class="headerlink" href="#tile-collision-editor" title="Permalink to this headline">¶</a></h3>
<p>
  通过单击工具栏上的<em>图块碰撞编辑器</em><a class="reference internal" href="_images/tile-collision-editor.png"><img alt="tile-collision-editor-icon" src="_images/tile-collision-editor.png" style="width: 24.0px; height: 24.0px;" /></a>按钮，可以使用图块碰撞编辑器。这将打开一个视图，您可以在其中创建和编辑图块上的形状。也可以将自定义特性与每个形状相关联。
 </p>
<p>
  通常，这些形状为某个精灵图或某个表示水平几何体的图块定义碰撞信息，但当然也可以使用它们为精灵图添加某些热点，例如粒子发射器或枪声源。
</p>
<div class="figure" id="id5">
<img alt="Tile Collision Editor" src="_images/tile-collision-editor1.png" />
<p class="caption"><span class="caption-text">图块碰撞编辑器</span></p>
</div>
<div class="new new-prev">Since Tiled 1.3</div><p></p>
  为了能够轻松检查您的图块是否设置了正确的碰撞形状，可以在地图上渲染它们。要启用此功能，请选中<em>视图</em>菜单中的<em>显示图块碰撞形状</em>。将为图块层和图块对象渲染碰撞形状。
</p>
<div class="figure" id="id6">
<img alt="Showing Tile Collision on the Map" src="_images/view-tile-collisions.png" />
<p class="caption"><span class="caption-text">
  在地图上渲染的碰撞形状。这张地图来自<a class="reference external" href="https://store.steampowered.com/app/1020940/Owyns_Adventure/">Owyn’s Adventure</a>
</span></p>
</div>
</div>
<div class="section" id="tile-animation-editor">
<span id="id4"></span><h3>图块动画编辑器<a class="headerlink" href="#tile-animation-editor" title="Permalink to this headline">¶</a></h3>
<p></p>
  图块动画编辑器允许通过将图块集中的其他图块作为其帧来定义单个线性循环动画。通过单击 <em>图块动画编辑器</em> <img alt="tile-animation-editor-icon" src="_images/animation-edit.png" />按钮将其打开。
  
</p>
<p>
  图块动画可以在Tiled中实时预览，这有助于获得游戏中的感觉。可以通过<em>视图 &gt; 显示图块动画</em>打开或关闭预览。
 </p>
<div class="figure" id="id7">
<img alt="Tile Animation Editor" src="_images/tile-animation-editor.png" />
<p class="caption"><span class="caption-text">Tile Animation Editor</span></p>
</div>
<p>
  以下步骤允许添加或编辑平铺动画：
</p>
<ul class="simple">
<li>
  在主Tiled窗口中选择图块。这将使<em>图块动画编辑器</em>窗口显示与该平铺关联的（最初为空）动画，以及图块集中的所有其他图块。
</li>
<li>
  将图块从图块集视图中拖拽进图块动画编辑器的左侧列表中，以添加动画帧。可以同时拖动多个图块。每个新帧的默认持续时间为100毫秒（或使用顶部的<span class="guilabel">帧时长</span>字段设置的其他值）。
</li>
<li>
  双击它以改变它的帧时长。
 </li>
<li>
  在列表中拖动帧以重新排序。
</li>
</ul>
<p>
  动画的预览显示在左下角。
</p>
<p>
  通过选择多个帧，更改<span class="guilabel">帧时长</span>字段中的值，然后单击<span class="guilabel">应用</span>，可以一次更改多个帧时长。
</p>
<div class="future topic">
<p class="topic-title first">Future Extensions</p>
<p>There are many ways in which the tileset editor can be made more
efficient, for example:</p>
<p><strong>Wang Sets</strong></p>
<ul class="simple">
<li>Make it easier to set up Wang tiles (<a class="reference external" href="https://github.com/bjorn/tiled/issues/1729">#1729</a>)</li>
</ul>
<p><strong>Tile Collision Editor</strong></p>
<ul class="simple">
<li>Allow setting collisions for multiple tiles at once (<a class="reference external" href="https://github.com/bjorn/tiled/issues/1322">#1322</a>)</li>
<li>Render tile collision shapes to the tileset view (<a class="reference external" href="https://github.com/bjorn/tiled/issues/1281">#1281</a>)</li>
</ul>
<p><strong>Tile Animation Editor</strong></p>
<ul class="simple">
<li>Support multiple named animations per tile (<a class="reference external" href="https://github.com/bjorn/tiled/issues/986">#986</a>)</li>
<li>Make it easier to define animations spanning multiple tiles (<a class="reference external" href="https://github.com/bjorn/tiled/issues/811">#811</a>)</li>
</ul>
<p>If you like any of these plans, please help me getting around to it
faster by <a class="reference external" href="https://www.mapeditor.org/donate">sponsoring Tiled development</a>. The
more support I receive the more time I can afford to spend improving
Tiled!</p>
</div>
</div>
</div>
<span id="document-manual/custom-properties"></span><div class="section" id="custom-properties">
<h2>自定义属性<a class="headerlink" href="#custom-properties" title="Permalink to this headline">¶</a></h2>
<p>
  Tiled的一个主要优点是它允许在其所有基本数据结构上设置自定义属性。
  通过这种方式，可以包含多种形式的自定义信息，这些信息稍后可供游戏或用于集成Tiled地图的框架使用。
</p>
<p>
  自定义属性将显示在“属性”视图中。
  此视图与上下文相关，通常显示最后选定对象的属性。对于图块集中的图块或对象图层上的对象，支持多重选择。
</p>
<div class="figure" id="id4">
<img alt="Properties View" src="_images/properties-dock.png" />
<p class="caption"><span class="caption-text">属性视图</span></p>
</div>
<div class="section" id="adding-properties">
<h3>添加属性<a class="headerlink" href="#adding-properties" title="Permalink to this headline">¶</a></h3>
<p>
  当你添加一个属性（使用属性界面下面的“+”号），系统将提示您输入其名称和类型。
  当前Tiled支持以下基本属性类型：
</p>
<ul class="simple">
<li><strong>bool</strong> (true or false)</li>
<li><strong>color</strong> (32位颜色值)</li>
<li><strong>file</strong> (引用文件的相对路径)</li>
<li><strong>float</strong> (浮点数)</li>
<li><strong>int</strong> (一个整数)</li>
<li><strong>object</strong> (对对象的引用) - <em>Since Tiled 1.4</em></li>
<li><strong>string</strong> (任何文本，包括多行文本)</li>
</ul>
<div class="figure" id="id5">
<a class="reference internal image-reference" href="_images/add-property.png"><img alt="Add Property Dialog" src="_images/add-property.png" style="width: 296.34000000000003px; height: 93.06px;" /></a>
<p class="caption"><span class="caption-text">添加属性对话框</span></p>
</div>
<p>
  属性类型用于在“属性”视图中选择自定义编辑器。
  在“属性”视图中，属性类型用于选择自定义编辑器。
  选择数字或布尔类型还可以避免在JSON和Lua导出中引用该值。
</p>
<div class="new">New in Tiled 1.4</div><p>
  自定义文件属性的上下文菜单提供了在首选编辑器中打开文件的快速方法。对于对象引用，有一个动作可以快速跳转到被引用对象。
</p>
<div class="new new-prev">Since Tiled 1.0</div></div>
<div class="section" id="tile-property-inheritance">
<span id="id1"></span><h3>继承图块属性<a class="headerlink" href="#tile-property-inheritance" title="Permalink to this headline">¶</a></h3>
<p>
  将自定义特性添加到图块时，这些特性也将在选定该图块的对象实例时可见。
  这使每个对象可以轻松地覆盖与图块关联的某些默认属性。当与<a class="reference internal" href="#typed-tiles"><span class="std std-ref">类型化图块</span></a>结合使用时，这变得特别有用。
</p>
<p>
  继承的属性将显示为灰色（禁用的文本颜色），而覆盖的属性将显示为黑色（通常的文本颜色）。
</p>
</div>
<div class="section" id="predefining-properties">
<span id="id2"></span><h3>预定义属性<a class="headerlink" href="#predefining-properties" title="Permalink to this headline">¶</a></h3>
<div class="section" id="general-setup">
<h4>通用设置<a class="headerlink" href="#general-setup" title="Permalink to this headline">¶</a></h4>
<p>
  通常你在游戏中只使用有限的一组对象类型，每种类型的对象都有一组固定的可能属性，具有特定的类型和默认值。
  为了节省时间，Tiled允许根据对象的“类型”字段预定义这些属性。可以使用<em>视图</em>菜单中的“对象类型编辑器”来设置此选项。
</p>
<div class="figure" id="id6">
<a class="reference internal image-reference" href="_images/object-types-editor.png"><img alt="Object Types Editor" src="_images/object-types-editor.png" style="width: 645.48px; height: 310.2px;" /></a>
<p class="caption"><span class="caption-text">对象类型编辑器</span></p>
</div>
<p>
  默认情况下，Tiled全局存储这些对象类型。但是，由于您经常希望与项目中的其他人共享对象类型，因此可以导出对象类型或更改<a class="reference internal" href="index.html#document-manual/projects"><span class="doc">项目</span></a>的对象类型文件的存储位置。
  一个简单的XML或JSON文件包含自解释的内容，用于存储对象类型。
</p>
<p>
  颜色不仅影响对象的各种形状的渲染，而且也是标签的颜色，如果为对象命名，标签将显示出来。
</p>
<p>
  要使预定义的属性显示在属性视图中，只需在内置的类型属性中输入类型的名称。
</p>
<div class="new new-prev">Since Tiled 1.0</div></div>
<div class="section" id="typed-tiles">
<span id="id3"></span><h4>类型化图块<a class="headerlink" href="#typed-tiles" title="Permalink to this headline">¶</a></h4>
<p>
  如果使用的是<a class="reference internal" href="index.html#insert-tile-tool"><span class="std std-ref">图块对象</span></a>，则可以在图块上设置类型，以避免必须在每个对象实例上设置类型。
  
  在图块上设置类型可以使预定义的属性在选定图块时可见，从而允许覆盖这些值。它还使那些可能被覆盖的值在选择了一个图块对象实例时可见，再次允许您覆盖它们。
</p>
<p>
  这方面的一个示例用例是使用诸如“name”、“health”或“weight”等属性定义自定义类型，如“NPC”、“敌方”或“Item”。然后可以在表示这些实体的分片上指定这些值。
</p>
<div class="future topic">
<p class="topic-title first">Future Extensions</p>
<p>There are several types of custom properties I’d like to add:</p>
<ul class="simple">
<li><strong>Enumerations</strong>, where you can predefine all possible values and it
forms a combo box
(<a class="reference external" href="https://github.com/bjorn/tiled/issues/1211">#1211</a>).</li>
<li><strong>Array properties</strong>, which would be properties having a list of
values (<a class="reference external" href="https://github.com/bjorn/tiled/issues/1493">#1493</a>).</li>
<li><strong>Dictionary properties</strong>, which would be properties that can contain
any number of other properties as children
(<a class="reference external" href="https://github.com/bjorn/tiled/issues/489">#489</a>).</li>
</ul>
<p>It would also be nice to add support for <strong>limiting property values</strong>,
like the length of string properties or a minimum/maximum on number
values.</p>
<p>Apart from predefining properties based on object type, I’d like to add
support for <strong>predefining the properties for each data type</strong>. So
defining which custom properties are valid for maps, tilesets, layers,
etc. (<a class="reference external" href="https://github.com/bjorn/tiled/issues/1410">#1410</a>)</p>
<p>If you like any of these plans, please help me getting around to it
faster by <a class="reference external" href="https://www.mapeditor.org/donate">sponsoring Tiled development</a>. The
more support I receive the more time I can afford to spend improving
Tiled!</p>
</div>
</div>
</div>
</div>
<span id="document-manual/using-templates"></span><div class="new new-prev">Since Tiled 1.1</div><div class="section" id="using-templates">
<h2>使用模板<a class="headerlink" href="#using-templates" title="Permalink to this headline">¶</a></h2>
<p>
  任何创建的对象都可以保存为模板。然后，这些模板可以在其他地方实例化为继承模板属性的对象。
  这样可以省去很多设置对象类型和属性的繁琐工作，甚至可以在图块集中找到正确的图块。
</p>
<p>
  每个模板都存储在自己的文件中，在那里可以将它们组织到目录中。可以将模板保存为XML或JSON格式，就像地图和图块集文件一样。
 </p>
<div class="figure">
<img alt="Templates Overview" src="_images/templates-overview.png" />
</div>
<div class="section" id="creating-templates">
<h3>创建模板<a class="headerlink" href="#creating-templates" title="Permalink to this headline">¶</a></h3>
<p>
  右键单击地图中的任何对象并选择“保存为模板”即可创建模板。
  系统将要求您选择保存模板的文件名和格式。如果对象已经有一个名称，则建议的文件名将基于该名称。
</p>
<div class="figure">
<img alt="New Template Dialog" src="_images/creating-templates.gif" />
</div>
<div class="new">New in Tiled 1.4</div><p>
  为了能够选择要编辑或实例化的模板，通常需要使用<a class="reference internal" href="index.html#document-manual/projects"><span class="doc">项目视图</span></a>，因此请确保将模板保存在项目的一部分文件夹中。也可以从文件管理器中拖动模板。
 </p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">
  不能从使用嵌入图块集的图块对象创建模板，因为<a class="reference internal" href="index.html#tmx-template-files"><span class="std std-ref">模板文件</span></a> 不支持引用此类图块集。
</p>
</div>
</div>
<div class="section" id="creating-template-instances">
<span id="id1"></span><h3>创建模板实例<a class="headerlink" href="#creating-template-instances" title="Permalink to this headline">¶</a></h3>
<p>Shortcut: <code class="docutils literal notranslate"><span class="pre">V</span></code></p>
<p>
  模板实例化的工作方式是将模板从项目视图拖放到地图上，或者使用“插入模板”工具选择模板并单击地图。如果要创建多个实例，后者更方便。
</p>
<div class="figure">
<img alt="Creating Instances" src="_images/creating-instances.gif" />
</div>
</div>
<div class="section" id="editing-templates">
<h3>编辑模板<a class="headerlink" href="#editing-templates" title="Permalink to this headline">¶</a></h3>
<p>
  使用<em>模板编辑器</em>视图编辑模板。通过在项目视图中选择木板或在木板编辑器视图中拖动模板文件，可以打开模板进行编辑。也可以使用<em>在项目中打开文件</em>操作来选择模板。
</p>
<p>
  在<em>模板编辑器</em>视图中选择模板时，<em>属性</em>视图将显示模板的属性，可以在其中进行编辑。
</p>
<div class="figure">
<img alt="Editing Templates" src="_images/editing-templates.gif" />
</div>
<p>
  如果模板实例的属性被更改，它将在内部标记为重写的属性，并且在模板更改时不会更改。
</p>
<div class="new">New in Tiled 1.4</div><p>
  如果一个模板文件在磁盘上发生了变化，它将自动重新加载，并且任何更改都将反映在<em>模板编辑器</em>和任何模板实例上。
</p>
</div>
<div class="section" id="detaching-template-instances">
<h3>拆分模板实例<a class="headerlink" href="#detaching-template-instances" title="Permalink to this headline">¶</a></h3>
<p>
  拆分模板实例将断开它与模板的连接，因此对模板的任何进一步编辑都不会影响分离的实例。
  要拆分实例，请右键单击该实例并选择“拆分”。
  如果地图加载器不支持对象模板，但仍希望使用它们，则可以在 <a class="reference internal" href="index.html#export-options"><span class="std std-ref">导出设置</span></a>中启用<em>分离模板</em>选项。
</p>
<div class="future topic">
<p class="topic-title first">Future Extensions</p>
<blockquote>
<div><ul class="simple">
<li>Resetting overridden properties individually (<a class="reference external" href="https://github.com/bjorn/tiled/issues/1725">#1725</a>).</li>
<li>Locking template properties (<a class="reference external" href="https://github.com/bjorn/tiled/issues/1726">#1726</a>).</li>
<li>Handling wrong file paths (<a class="reference external" href="https://github.com/bjorn/tiled/issues/1732">#1732</a>).</li>
<li>Managing the templates folder, e.g. moving, renaming or deleting a template or a sub-folder
(<a class="reference external" href="https://github.com/bjorn/tiled/issues/1723">#1723</a>).</li>
</ul>
</div></blockquote>
</div>
</div>
</div>
<span id="document-manual/using-the-terrain-tool"></span><div class="section" id="using-the-terrain-brush">
<h2>使用地形刷<a class="headerlink" href="#using-the-terrain-brush" title="Permalink to this headline">¶</a></h2>
<p>
  添加<a class="reference internal" href="index.html#terrain-tool"><span class="std std-ref">地形刷</span></a> 是为了当使用地形过渡的时候更容易编辑图块地图。
  当然有多种方法可以在图块之间进行转换。
  此工具支持在其4个角上具有定义良好的地形类型的过渡平铺，这似乎是最常用的方法。
</p>
<p>
  为了演示如何使用此工具，我们描述了重现<code class="file docutils literal notranslate"><span class="pre">desert.tmx</span></code>示例地图，现在地形信息也包含在其图块集中。
</p>
<div class="section" id="create-a-new-map-and-add-a-tileset">
<h3>创建一个新的地图并添加图块集<a class="headerlink" href="#create-a-new-map-and-add-a-tileset" title="Permalink to this headline">¶</a></h3>
<p>
  
  首先，按照<a class="reference internal" href="index.html#getting-started"><span class="std std-ref">开始使用</span></a>设置地图和图块集。
</p>
<p>
  关于<code class="file docutils literal notranslate"><span class="pre">tmw_desert_spacing.png</span></code>，我们设置了4种不同的地形类型。
  传统上使用这些图块编辑地图意味着必须小心连接正确的过渡，以避免断边。
  现在我们将为这个图块集定义地形信息，<a class="reference internal" href="index.html#terrain-tool"><span class="std std-ref">地形刷</span></a>将使用它自动放置正确的过渡。
</p>
</div>
<div class="section" id="define-the-terrain-information">
<span id="define-terrain-information"></span><h3>定义地形信息<a class="headerlink" href="#define-the-terrain-information" title="Permalink to this headline">¶</a></h3>
<p>
  首先，切换到图块集文件。如果您正在查看地图并选择了图块集，则可以通过单击图块集视图下的小<em>编辑图块集</em>按钮来完成此操作。
</p>
<div class="figure" id="id1">
<img alt="Edit Tileset button" src="_images/01-edittilesetbutton.png" />
<p class="caption"><span class="caption-text">编辑图块集按钮</span></p>
</div>
<p>
  然后，单击工具栏上的<em>地形</em>
  <img alt="terrain" src="_images/terrain.png" /> 按钮激活地形编辑模式。
</p>
<p>
  在此模式下，将显示地形类型的列表，您可以将图块集中的图块的角标记为属于特定地形类型。
  首先，添加4种地形类型。最快的方法是右键单击表示特定地形的平铺，然后选择“添加地形类型”。这会自动将平铺设置为表示地形的图像。
  最快的方法是右键单击表示特定地形的图块，然后选择<span class="guilabel">增加地形类型</span>。
  这会自动将图块设置为表示地形的图像。
</p>
<div class="figure" id="id2">
<img alt="Adding Terrain Type" src="_images/02-editterraindialog-add.png" />
<p class="caption"><span class="caption-text">增加地形类型</span></p>
</div>
<p>
  给每个地形一个合适的名字。完成后，选择沙地地形并用这种地形类型标记图块集中的所有角。结果应该如下所示：
</p>
<div class="figure" id="id3">
<img alt="Sand Terrain Marked" src="_images/03-editterraindialog-edit.png" />
<p class="caption"><span class="caption-text">标记沙地地形</span></p>
</div>
<p>
  为了了解我们是如何做到这一点的，我们来看看一块在沙子和泥土之间过渡的图块。
  选择沙地地形后，单击并拖动以将此图块的左上角、右上角和左下角标记为“沙子”。
  右下角还没有标记，一旦我们标记了所有的脏角，我们将获得那个角。
</p>
<div class="figure">
<img alt="Marked Tile With Sand and Dirt" src="_images/07-terrain-marked-tile.png" />
</div>
<p>
  如果出错，只需使用“撤消”（或按<code class="docutils literal notranslate"><span class="pre">Ctrl+Z</span></code>）。或者，如果以后注意到错误，请使用“擦除地形”从拐角处清除地形类型，或者选择正确的地形类型并在其上绘制。每个角点只能有一种与之关联的地形类型。
  
</p>
<div class="figure" id="id4">
<img alt="Done Marking Terrain" src="_images/04-editterraindialog-done.png" />
<p class="caption"><span class="caption-text">完成地形标记</span></p>
</div>
<p>
  现在您可以通过再次单击工具栏按钮来禁用 <em>地形</em> <img alt="terrain" src="_images/terrain.png" />模式。
</p>
</div>
<div class="section" id="editing-with-the-terrain-brush">
<h3>使用地形刷编辑<a class="headerlink" href="#editing-with-the-terrain-brush" title="Permalink to this headline">¶</a></h3>
<p>
  切换回地图，然后激活地形窗口。
  您应该会看到列表中表示的4种地形类型。
  单击沙地地形并开始绘制。你可能会立刻注意到没有什么特别的事情发生。
  这是因为地图上还没有其他图块，所以地形工具并不真正知道如何帮助（因为我们没有过渡到“没有”在我们的图块集中）。
  假设我们要创建一个沙漠地图，最好先用沙子填充整个地图。只需切换回图块集窗口一会儿，选择沙图块，然后使用<a class="reference internal" href="index.html#bucket-fill-tool"><span class="std std-ref">填充工具</span></a>。
</p>
<p>
  我们切换回地形窗口，画一些鹅卵石。现在你可以看到工具的作用了！
</p>
<div class="figure" id="id5">
<img alt="Drawing Cobblestone" src="_images/05-drawing-cobblestone.png" />
<p class="caption"><span class="caption-text">绘制鹅卵石</span></p>
</div>
<p>
  在绘图时尝试按住<code class="docutils literal notranslate"><span class="pre">Control</span></code> (<code class="docutils literal notranslate"><span class="pre">Command</span></code> on a Mac)。这样可以将修改区域缩小到离鼠标最近的一个角落，从而可以进行精确的工作。
</p>
<p>
  最后，看看在鹅卵石上画些土会发生什么。因为没有直接从泥土到鹅卵石的过渡，地形工具首先将过渡插入到沙子，然后从那里插入到鹅卵石。整洁！
</p>
<div class="figure" id="id6">
<img alt="Drawing Dirt" src="_images/06-drawing-dirt.png" />
<p class="caption"><span class="caption-text">绘制泥土</span></p>
</div>
</div>
<div class="section" id="final-words">
<h3>结束语<a class="headerlink" href="#final-words" title="Permalink to this headline">¶</a></h3>
<p>
  现在你应该对如何在你自己的项目中使用这个工具有了一个很好的想法。请记住以下几点：
</p>
<ul class="simple">
<li>
  目前，该工具要求所有地形类型都是同一个图块集的一部分。在地图中可以有多个具有地形的图块集，但该工具无法执行从一个图块集到另一个图块集中的地形的自动过渡。这通常意味着您可能需要将多个图块组合成一个图像。
 </li>
<li>
  由于定义地形信息可能有些费力，因此您应该避免使用嵌入的图块集，以便可以在多个地图之间共享地形信息。
</li>
<li>
  地形工具可以很好地处理等距地图。要确保正确显示地形覆盖，请在“图块集属性”中设置<em>方向</em>、<em>栅格宽度</em>和<em>栅格高度</em>。
</li>
<li>
  该工具将处理任意数量的地形类型，并且图块的每个角可以有不同类型的地形。不过，还有其他方法可以处理此工具无法处理的转换。而且，它不能同时编辑多个图层。为了更灵活，但也更复杂的方式自动放置图块，查看<a class="reference internal" href="index.html#document-manual/automapping"><span class="doc">自动映射</span></a>。
</li>
<li>
  我正在维护一个<a class="reference external" href="http://opengameart.org/content/terrain-transitions">图块集集合</a>，这些图块集包含与上的此工具兼容的转换OpenGameArt.org.
  I’m maintaining a <a class="reference external" href="http://opengameart.org/content/terrain-transitions">collection of
tilesets</a> that
contain transitions that are compatible with this tool on
<a class="reference external" href="http://opengameart.org/">OpenGameArt.org</a>.</li>
</ul>
</div>
</div>
<span id="document-manual/using-wang-tiles"></span><div class="new new-prev">Since Tiled 1.1</div><div class="section" id="using-wang-tiles">
<h2>使用王氏图块<a class="headerlink" href="#using-wang-tiles" title="Permalink to this headline">¶</a></h2>
<p>
  王氏图块在概念上与<a class="reference internal" href="index.html#document-manual/using-the-terrain-tool"><span class="doc">地形</span></a>相似。然而，他们更专注于填补更大的领域而不重复。
  一种方法是定义图块集中图块的边缘和角落颜色。
  然后，在填充或刷涂时可以使用此信息，以便在图块之间平滑、不重复地过渡。
  在大多数情况下，这种平铺是随机的，并且基于颜色概率。更多关于王氏图块的信息可以在<a class="reference external" href="http://www.cr31.co.uk/stagecast/wang/intro.html">这里</a>找到。
</p>
<p>
  为了演示如何使用Wang tiles，我们将描述重新创建所需的步骤<code class="docutils literal notranslate"><span class="pre">walkways.tsx</span></code>示例图块图集。
</p>
<div class="section" id="defining-wang-tile-info">
<span id="id1"></span><h3>定义王氏图块信息<a class="headerlink" href="#defining-wang-tile-info" title="Permalink to this headline">¶</a></h3>
<p>
  制作图块集之后，从图块集编辑器中，单击王氏图块集按钮。
</p>
<div class="figure" id="id2">
<img alt="_images/01-wangbutton.jpg" src="_images/01-wangbutton.jpg" />
<p class="caption"><span class="caption-text">王氏图块集按钮</span></p>
</div>
<p>
  一个图块集可以有多个王氏图块集。使用王氏图块集视图底部的加号按钮创建一个新的王氏图块集。
</p>
<div class="figure" id="id3">
<img alt="_images/02-wangsetview.jpg" src="_images/02-wangsetview.jpg" />
<p class="caption"><span class="caption-text">王氏图块集视图</span></p>
</div>
<p>
  现在可以编辑王氏图块集的属性。
  对我们来说重要的是边角计数。这将决定如何定义集合及其行为。这是一个3边的王氏图块集。
 </p>
<div class="figure" id="id4">
<img alt="_images/03-wangsetproperties.jpg" src="_images/03-wangsetproperties.jpg" />
<p class="caption"><span class="caption-text">王氏图块集属性</span></p>
</div>
<p>
  现在，完整的模式集将在王氏图块集视图下的<em>模式</em>选项卡中生成。为了使集合完整（尽管这是不必要的），每个模式必须至少使用一次。
</p>
<div class="figure" id="id5">
<img alt="_images/04-patternview.jpg" src="_images/04-patternview.jpg" />
<p class="caption"><span class="caption-text">模式视图</span></p>
</div>
<p>
  选定模式后，可以直接将其绘制到图块集上。与使用图章刷时类似， <code class="docutils literal notranslate"><span class="pre">Z</span></code>和<code class="docutils literal notranslate"><span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">Z</span></code>可分别用于顺时针和逆时针旋转图案90度。<code class="docutils literal notranslate"><span class="pre">X</span></code>和 <code class="docutils literal notranslate"><span class="pre">Y</span></code>分别水平和垂直翻转图案。
</p>
<div class="figure" id="id6">
<img alt="_images/05-assigningpattern.jpg" src="_images/05-assigningpattern.jpg" />
<p class="caption"><span class="caption-text">模式绘制</span></p>
</div>
<p>
  在另一个选项卡中，有<em>颜色</em>视图。这使您可以编辑属性并为集指定一个颜色。
</p>
<div class="figure" id="id7">
<img alt="_images/06-assigningedge.jpg" src="_images/06-assigningedge.jpg" />
<p class="caption"><span class="caption-text">单独喷涂边缘</span></p>
</div>
<p>
  使用这些方法，指定与所有边匹配的每个图块。完成这项工作后，这套设备就可以与所有王式方法一起使用了。
 </p>
<div class="figure" id="id8">
<img alt="_images/07-fullassignment.jpg" src="_images/07-fullassignment.jpg" />
<p class="caption"><span class="caption-text">完整的分配王氏图集</span></p>
</div>
</div>
<div class="section" id="editing-with-wang-methods">
<h3>使用王氏方法编辑<a class="headerlink" href="#editing-with-wang-methods" title="Permalink to this headline">¶</a></h3>
<p>
  王氏图块的使用方法主要有两种：
</p>
<ul class="simple">
<li>激活<a class="reference external" href="#wang-mode">王氏模式</a></li>
<li>使用<a class="reference external" href="#wang-brush">王氏笔刷</a></li>
</ul>
<div class="section" id="wang-mode">
<h4>王氏模式<a class="headerlink" href="#wang-mode" title="Permalink to this headline">¶</a></h4>
<p>
  类似于随机模式，印章刷，和桶填充工具可以使用王氏方法来填充。
 当王氏模式被激活是，将随机从相邻的单元格中选择匹配的所有颜色。
</p>
<div class="figure" id="id9">
<img alt="_images/08-stampbrush.jpg" src="_images/08-stampbrush.jpg" />
<p class="caption"><span class="caption-text">Stamp Brush with Wang Fill Mode Enabled</span></p>
</div>
<div class="figure" id="id10">
<img alt="_images/09-bucketfill.jpg" src="_images/09-bucketfill.jpg" />
<p class="caption"><span class="caption-text">Bucket Fill with Wang Fill Mode Enabled</span></p>
</div>
</div>
<div class="section" id="wang-brush">
<h4>王氏刷子<a class="headerlink" href="#wang-brush" title="Permalink to this headline">¶</a></h4>
<p>
  还有<a class="reference internal" href="index.html#wang-tool"><span class="std std-ref">王氏刷子</span></a>，它的工作原理很像地形刷。

  此工具可更改相邻单元格的边/颜色模式，以匹配选定的颜色。如果瓦片中不存在王氏图集的某一特定模式，则该区域不能涂漆。
 </p>
<div class="figure" id="id11">
<img alt="_images/10-wangbrush.jpg" src="_images/10-wangbrush.jpg" />
<p class="caption"><span class="caption-text">Wang Brush</span></p>
</div>
</div>
</div>
<div class="section" id="customizing-wang-colors">
<h3>自定义王氏颜色<a class="headerlink" href="#customizing-wang-colors" title="Permalink to this headline">¶</a></h3>
<p>
  每一种王氏颜色都可以定制，以便更容易识别。此外，每种颜色的概率都可以调整，这样在王氏模式下，它将更频繁地出现在填充或刷子中。
</p>
<div class="section" id="color-appearance">
<h4>颜色外观<a class="headerlink" href="#color-appearance" title="Permalink to this headline">¶</a></h4>
<p>
  名字，图像，当然还有颜色都可以改变王氏颜色的外观。可以通过选择一种颜色，然后右键单击所需图像的磁贴，然后选择<em>设置王氏图块集的颜色图像</em>来更改此图像。
</p>
<div class="figure" id="id12">
<img alt="_images/11-setwangcolorimage.jpg" src="_images/11-setwangcolorimage.jpg" />
<p class="caption"><span class="caption-text">Selecting Wang color image</span></p>
</div>
<div class="figure" id="id13">
<img alt="_images/12-wangcolorproperties.jpg" src="_images/12-wangcolorproperties.jpg" />
<p class="caption"><span class="caption-text">其他值可以从属性视图更改。</span></p>
</div>
</div>
<div class="section" id="probability">
<h4>概率<a class="headerlink" href="#probability" title="Permalink to this headline">¶</a></h4>
<p>
  使用王氏方法选择图块时，将考虑具有有效王氏模式的所有图块。根据边缘/角点颜色的概率为它们指定权重。然后随机选择一个，同时考虑这个权重。权重是所有概率的乘积。
</p>
<a class="reference internal image-reference" href="_images/13-lowprobability.jpg"><img alt="_images/13-lowprobability.jpg" src="_images/13-lowprobability.jpg" style="width: 45%;" /></a>
<a class="reference internal image-reference" href="_images/14-highprobability.jpg"><img alt="_images/14-highprobability.jpg" src="_images/14-highprobability.jpg" style="width: 45%;" /></a>
<p>Left shows path with probability 0.1, right shows path with probability 10.</p>
</div>
</div>
<div class="section" id="standard-wang-sets">
<h3>标准王氏图集<a class="headerlink" href="#standard-wang-sets" title="Permalink to this headline">¶</a></h3>
<p>
  一些典型的王氏图集是 <a class="reference external" href="http://www.cr31.co.uk/stagecast/wang/2corn.html">2角</a>，
  <a class="reference external" href="http://www.cr31.co.uk/stagecast/wang/2edge.html">2边</a>，和<a class="reference external" href="http://www.cr31.co.uk/stagecast/wang/blob.html">点</a>。王氏图块在Tiled中支持多达15个边缘和15个角落的颜色在一图集。
  
 </p>
</div>
</div>
<span id="document-manual/using-infinite-maps"></span><div class="new new-prev">Since Tiled 1.1</div><div class="section" id="using-infinite-maps">
<h2>使用无限地图<a class="headerlink" href="#using-infinite-maps" title="Permalink to this headline">¶</a></h2>
<p>
  无限地图使您独立于地图的边界。画布是“自动增长”，这基本上意味着，你有一个无限的网格，可以在上面绘制，而不必担心地图的宽度和高度。每当在当前边界之外绘制图块时，特定层的边界将扩展。
</p>
<div class="figure">
<img alt="Infinite Maps Overview" src="_images/infinite-map-overview.png" />
</div>
<div class="section" id="creating-an-infinite-map">
<h3>创建一个无限地图<a class="headerlink" href="#creating-an-infinite-map" title="Permalink to this headline">¶</a></h3>
<p>
  要创建无限地图，请确保在“新建地图”对话框中选择了“无限”选项。
</p>
<div class="figure">
<a class="reference internal image-reference" href="_images/infinite-new.png"><img alt="New Infinite Map" src="_images/infinite-new.png" style="width: 380.82px; height: 396.66px;" /></a>
</div>
<p>
  新创建的地图将有一个无限的画布。
</p>
</div>
<div class="section" id="editing-the-infinite-map">
<h3>编辑无限地图<a class="headerlink" href="#editing-the-infinite-map" title="Permalink to this headline">¶</a></h3>
<p>
  除了<a class="reference internal" href="index.html#bucket-fill-tool"><span class="std std-ref">填充工具</span></a>外，所有工具的工作方式与固定尺寸地图中的完全相同。填充工具填充特定图块层的当前范围。这些界限会随着图块层的进一步绘制而增加。
  
 </p>
<div class="figure">
<img alt="Infinite Maps Editing" src="_images/infinite-demo.gif" />
</div>
</div>
<div class="section" id="conversion-from-infinite-to-finite-map-and-vice-versa">
<h3>无限地图、有限地图的相互转换<a class="headerlink" href="#conversion-from-infinite-to-finite-map-and-vice-versa" title="Permalink to this headline">¶</a></h3>
<p>
  在地图属性中，您可以切换地图是否应该是无限的。当从无限地图转换为有限映射时，最终地图的宽度和高度是根据所有图块层的边界来决定的。
</p>
<div class="figure" id="id1">
<img alt="Initial Map" src="_images/infinite-map-initial.png" />
<p class="caption"><span class="caption-text">初始无限地图</span></p>
</div>
<div class="figure" id="id2">
<img alt="Properties" src="_images/infinite-map-conversion.png" />
<p class="caption"><span class="caption-text">取消选中地图属性中的无限属性</span></p>
</div>
<div class="figure" id="id3">
<img alt="Final Map" src="_images/infinite-map-converted.png" />
<p class="caption"><span class="caption-text">转换后的地图</span></p>
</div>
</div>
</div>
<span id="document-manual/worlds"></span><div class="new new-prev">Since Tiled 1.2</div><div class="section" id="working-with-worlds">
<h2>与世界配合工作<a class="headerlink" href="#working-with-worlds" title="Permalink to this headline">¶</a></h2>
<p>
  有时，一个游戏有一个大世界，它被多个地图分割，使这个世界更容易被游戏消化（内存使用更少），或者更容易被多个人编辑（避免合并冲突）。如果在同一视图中可以看到来自这样一个世界的地图，并且能够在编辑不同的地图之间快速切换，这将是非常有用的。定义一个世界可以让你做到这一点。
</p>
<div class="figure" id="id1">
<img alt="Many maps from The Mana World shown at once" src="_images/world-view.png" />
<p class="caption">
  <span class="caption-text"></span>许多<a class="reference external" href="https://www.themanaworld.org/">魔法世界</a>的地图同时显示。
  </span></p>
</div>
<div class="section" id="defining-a-world">
<h3>定义一个世界<a class="headerlink" href="#defining-a-world" title="Permalink to this headline">¶</a></h3>
<p>
  一个世界被定义在一个<code class="docutils literal notranslate"><span class="pre">.world</span></code>文件中，该文件是一个JSON文件，它告诉Tiled哪些地图是世界的一部分，位于什么位置。世界可以通过使用<em>地图 &gt; 新的地图…</em>行为来创建。
<p>
  您也可以手动创建<cite>.world 文件</cite>。下面是一个简单的世界定义示例，它定义了三个贴图的全局位置（以像素为单位）：
</p>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;maps&quot;</span><span class="p">:</span> <span class="p">[</span>
        <span class="p">{</span>
            <span class="s2">&quot;fileName&quot;</span><span class="p">:</span> <span class="s2">&quot;001-1.tmx&quot;</span><span class="p">,</span>
            <span class="s2">&quot;x&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;y&quot;</span><span class="p">:</span> <span class="mi">0</span>
        <span class="p">},</span>
        <span class="p">{</span>
            <span class="s2">&quot;fileName&quot;</span><span class="p">:</span> <span class="s2">&quot;002-1.tmx&quot;</span><span class="p">,</span>
            <span class="s2">&quot;x&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="s2">&quot;y&quot;</span><span class="p">:</span> <span class="mi">3200</span>
        <span class="p">},</span>
        <span class="p">{</span>
            <span class="s2">&quot;fileName&quot;</span><span class="p">:</span> <span class="s2">&quot;006-1.tmx&quot;</span><span class="p">,</span>
            <span class="s2">&quot;x&quot;</span><span class="p">:</span> <span class="mi">3840</span><span class="p">,</span>
            <span class="s2">&quot;y&quot;</span><span class="p">:</span> <span class="mi">4704</span>
        <span class="p">}</span>
    <span class="p">],</span>
    <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;world&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>
  定义后，需要通过从菜单中选择<em>地图 &gt; 载入世界…</em>来加载世界。可以同时加载多个世界，重新启动Tiled后，世界将再次自动加载。
 </p>
<p>
  当地图打开时，Tiled检查它是否是任何已加载世界的一部分。如果是这样，则同一世界中的任何其他地图也将加载并显示在打开的地图旁边。您可以单击任何其他地图以打开它们进行编辑，这将在保持视图处于相同位置的同时切换文件。
</p>
<p>
  当世界的文件在磁盘上更改时，它们会自动重新加载。
</p>
<div class="new">New in Tiled 1.4</div></div>
<div class="section" id="editing-worlds">
<h3>编辑世界<a class="headerlink" href="#editing-worlds" title="Permalink to this headline">¶</a></h3>
<p>
  一旦你加载了一个世界，你可以从工具栏中选择“世界工具”来添加、删除和移动世界中的地图。
</p>
<dl class="docutils">
<dt>添加地图</dt>
<dd>
  单击工具栏上的“将当前地图添加到已加载世界”按钮，从下拉菜单中选择要添加到的世界。
  要将不同的地图添加到当前世界，可以使用工具栏上的“添加其他地图到当前世界”按钮。或者，可以通过在地图编辑器中单击鼠标右键来访问这两个操作。
</dd>
<dt>移除地图</dt>
<dd>
  点击工具栏上的“从当前世界移除当前地图”按钮。或者，右键单击地图编辑器中的地图，然后从上下文菜单中选择“从世界删除…”操作。
</dd>
<dt>移动地图</dt>
<dd><p class="first">
  只需在地图编辑器中拖动地图。您可以通过单击“Escape”或右键单击来中止移动地图。
</p>
<p class="last">
  或者，您可以使用箭头键移动当前选定的地图-按住Shift键将执行更大的步长。
</p>
</dd>
<dt>保存世界文件</dt>
<dd>
  可以使用 <em>地图 &gt; 保存世界</em>菜单保存操纵的世界文件。当你在执行任何外部地图之前也会自动保存地图。
</dd>

</dl>
</div>
<div class="section" id="using-pattern-matching">
<h3>使用模式匹配<a class="headerlink" href="#using-pattern-matching" title="Permalink to this headline">¶</a></h3>
<p>
  对于地图遵循特定命名样式的项目，该样式允许从文件名导出世界上每个地图的位置，可以将正则表达式与乘数和偏移量结合使用。
</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">
  目前Tiled中不存在使用模式匹配定义世界的接口，也不能修改它。必须手动编辑具有模式的世界文件。
 </p>
</div>
<p>下面是一个示例:</p>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;patterns&quot;</span><span class="p">:</span> <span class="p">[</span>
        <span class="p">{</span>
            <span class="s2">&quot;regexp&quot;</span><span class="p">:</span> <span class="s2">&quot;ow-p0*(</span><span class="se">\\</span><span class="s2">d+)-n0*(</span><span class="se">\\</span><span class="s2">d+)-o0000</span><span class="se">\\</span><span class="s2">.tmx&quot;</span><span class="p">,</span>
            <span class="s2">&quot;multiplierX&quot;</span><span class="p">:</span> <span class="mi">6400</span><span class="p">,</span>
            <span class="s2">&quot;multiplierY&quot;</span><span class="p">:</span> <span class="mi">6400</span><span class="p">,</span>
            <span class="s2">&quot;offsetX&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">6400</span><span class="p">,</span>
            <span class="s2">&quot;offsetY&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">6400</span>
        <span class="p">}</span>
    <span class="p">],</span>
    <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;world&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>
  正则表达式与与世界文件位于同一目录中的所有文件匹配。它捕获两个数字，第一个被视为 <code class="docutils literal notranslate"><span class="pre">x</span></code>，第二个作为<code class="docutils literal notranslate"><span class="pre">y</span></code>。然后分别乘以<code class="docutils literal notranslate"><span class="pre">multiplierX</span></code>和<code class="docutils literal notranslate"><span class="pre">multiplierY</span></code>，最后添加<code class="docutils literal notranslate"><span class="pre">offsetX</span></code> 和<code class="docutils literal notranslate"><span class="pre">offsetY</span></code>。偏移主要是为了允许在同一世界中相对定位多组地图。最终值将成为每个地图的位置（以像素为单位）。
</p>
<p>
  世界定义可以使用手动定义的地图和模式的组合。
</p>
</div>
<div class="section" id="showing-only-direct-neighbors">
<h3>只显示直系邻居<a class="headerlink" href="#showing-only-direct-neighbors" title="Permalink to this headline">¶</a></h3>
<p>
  Tiled非常注意只加载每个地图、图块集和图像一次，但有时世界太大，无法完全加载。可能内存不足，或者渲染整个地图的速度太慢。
  在这种情况下，可以选择只加载当前地图的直接邻居。向顶层JSON对象添加<code class="docutils literal notranslate"><span class="pre">&quot;onlyShowAdjacentMaps&quot;:</span> <span class="pre">true</span></code>。
  </p>
<p>
  为了实现这一点，不仅需要定义每个地图的位置，还需要定义每个地图的大小。对于单个地图，这是使用<code class="docutils literal notranslate"><span class="pre">宽度</span></code>和<code class="docutils literal notranslate"><span class="pre">高度</span></code>属性完成的。对于模式，属性是<code class="docutils literal notranslate"><span class="pre">mapWidth</span></code>和<code class="docutils literal notranslate"><span class="pre">mapHeight</span></code>，为了方便起见，它们默认为已定义的乘数。所有值均以像素为单位。
</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">
  将来，我可能会更改此选项，以允许指定加载其他地图的当前贴图周围的距离。
 </p>
</div>
</div>
</div>
<span id="document-manual/using-commands"></span><div class="section" id="using-commands">
<h2>使用命令<a class="headerlink" href="#using-commands" title="Permalink to this headline">¶</a></h2>
<p>
  命令按钮允许您从Tiled创建和运行shell命令（其他程序）。
</p>
<p>
  您可以设置任意多个命令。如果您编辑多个游戏的地图，并且希望为每个游戏设置一个命令，这将非常有用。或者，您可以为加载不同检查点或配置的同一游戏设置多个命令。
</p>
<div class="section" id="the-command-button">
<h3>命令按钮<a class="headerlink" href="#the-command-button" title="Permalink to this headline">¶</a></h3>
<p>
  它位于“恢复”按钮右侧的主工具栏上。单击它将运行默认命令（命令列表中的第一个命令）。单击它旁边的箭头将显示一个菜单，该菜单允许您运行已设置的任何命令，以及打开“编辑命令”对话框的选项。您还可以在“文件”菜单中找到所有命令。
</p>
<p>
  除此之外，您还可以为每个命令设置自定义键盘快捷键。
</p>
</div>
<div class="section" id="editing-commands">
<h3>编辑命令<a class="headerlink" href="#editing-commands" title="Permalink to this headline">¶</a></h3>
<p>
  “编辑命令”对话框包含命令列表。每个命令都有几个属性：
</p>
<dl class="docutils">
<dt>名称</dt>
<dd>在下拉列表中可以很容易地识别它的名称。</dd>
<dt>可执行文件</dt>
<dd>要运行的可执行文件。它应该是完整路径或系统路径中可执行文件的名称。</dd>
<dt>参数</dt>
<dd>运行可执行文件的参数。</dd>
<dt>工作目录</dt>
<dd>工作目录的路径。</dd>
<dt>快捷键</dt>
<dd>
  用于触发命令的自定义键序列。您可以使用“清除”来重置快捷方式。
</dd>
<dt>在控制台显示输出</dt>
<dd>
  如果启用此选项，则此命令的输出（stdout和stderr）将显示在调试控制台中。您可以在 <em>视图 &gt; 视图和工具栏 &gt; 调试控制台</em>中找到调试控制台。
</dd>
<dt>执行前保存地图</dt>
<dd>如果启用此选项，则在执行命令之前将保存当前地图。</dd>
<dt>启动</dt>
<dd>
  一种快速禁用命令并将其从下拉列表中删除的方法。默认命令是第一个启用的命令。
 </dd>
</dl>
<p>
  注意，如果可执行文件或其任何参数包含空格，则需要引用这些部分。
</p>
<div class="section" id="substituted-variables">
<h4>替代变量<a class="headerlink" href="#substituted-variables" title="Permalink to this headline">¶</a></h4>
<p>
  在可执行文件、参数和工作目录字段中，可以使用以下变量：
</p>
<dl class="docutils">
<dt><code class="docutils literal notranslate"><span class="pre">%mapfile</span></code></dt>
<dd>当前映射完整路径。</dd>
<dt><code class="docutils literal notranslate"><span class="pre">%mappath</span></code></dt>
<dd>
  地图所在的完整文件夹路径。
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">%objecttype</span></code></dt>
<dd>
  当前选定对象的类型（如果有）。
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">%objectid</span></code></dt>
<dd>
  当前选定对象的ID（如果有）。
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">%layername</span></code></dt>
<dd>
  当前选定图层的名称。
</dd>
</dl>
<p>
  对于“工作目录”字段，还可以使用以下变量：
</p>
<dl class="docutils">
<dt><code class="docutils literal notranslate"><span class="pre">%executablepath</span></code></dt>
<dd>可执行文件的路径。</dd>
</dl>
</div>
</div>
<div class="section" id="example-commands">
<h3>示例命令<a class="headerlink" href="#example-commands" title="Permalink to this headline">¶</a></h3>
<p>
  使用-loadmap参数和mapfile启动名为“mygame”的自定义游戏：
</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mygame</span> <span class="o">-</span><span class="n">loadmap</span> <span class="o">%</span><span class="n">mapfile</span>
</pre></div>
</div>
<p>
  在Mac上，请记住应用程序是文件夹，因此您需要从<code class="docutils literal notranslate"><span class="pre">Contents/MacOS</span></code>文件夹中运行实际的可执行文件：
</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">/</span><span class="n">Applications</span><span class="o">/</span><span class="n">TextEdit</span><span class="o">.</span><span class="n">app</span><span class="o">/</span><span class="n">Contents</span><span class="o">/</span><span class="n">MacOS</span><span class="o">/</span><span class="n">TextEdit</span> <span class="o">%</span><span class="n">mapfile</span>
</pre></div>
</div>
<p>
  或使用<code class="docutils literal notranslate"><span class="pre">open</span></code>（注意引号，因为其中一个参数包含空格）：
 </p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">open</span> <span class="o">-</span><span class="n">a</span> <span class="s2">&quot;/Applications/CoronaSDK/Corona Simulator.app&quot;</span> <span class="o">/</span><span class="n">Users</span><span class="o">/</span><span class="n">user</span><span class="o">/</span><span class="n">Desktop</span><span class="o">/</span><span class="n">project</span><span class="o">/</span><span class="n">main</span><span class="o">.</span><span class="n">lua</span>
</pre></div>
</div>
<p>
  某些系统还具有在相应程序中打开文件的命令：
</p>
<ul class="simple">
<li>OSX: <code class="docutils literal notranslate"><span class="pre">open</span> <span class="pre">%mapfile</span></code></li>
<li>GNOME systems like Ubuntu: <code class="docutils literal notranslate"><span class="pre">gnome-open</span> <span class="pre">%mapfile</span></code></li>
<li>FreeDesktop.org standard: <code class="docutils literal notranslate"><span class="pre">xdg-open</span> <span class="pre">%mapfile</span></code></li>
</ul>
</div>
</div>
<span id="document-manual/automapping"></span><div class="section" id="automapping">
<h2>自动映射<a class="headerlink" href="#automapping" title="Permalink to this headline">¶</a></h2>
<div class="section" id="what-is-automapping">
<h3>什么是自动映射？<a class="headerlink" href="#what-is-automapping" title="Permalink to this headline">¶</a></h3>
<p>
  Automapping是一种高级工具，可以自动搜索地图中各层的某些分片组合，并将这些部分替换为另一个组合。这允许用户快速绘制结构，自动映射将从中生成一个复杂的场景，如果手工绘制，这将花费更多的时间。
</p>
<p>
  自动映射的目标是你只需要在一个图层内绘制，其他的一切都是为你设置的。这带来了一些好处：
</p>
<ul class="simple">
<li><strong>工作速度</strong> -你需要更少的时间来设置一个地图。</li>
<li><strong>更少的错误</strong> - 主要原因是为了降低错误率。如果正确设置了规则，则不存在隐藏错误。</li>
</ul>
<div class="section" id="external-links">
<h4>外部链接<a class="headerlink" href="#external-links" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://www.youtube.com/watch?v=UUi0lD1pxyQ">Automapping explained for Tiled 0.9 and later (YouTube)</a></li>
<li><a class="reference external" href="https://github.com/stefanbeller/tiled_examples">Examples on Automapping</a></li>
<li><a class="reference external" href="https://youtu.be/A_A6rz7cvG4">Tiled Map Editor Tutorial Part Three: AutoMap (YouTube)</a></li>
</ul>
</div>
</div>
<div class="section" id="setting-it-up">
<h3>设置它<a class="headerlink" href="#setting-it-up" title="Permalink to this headline">¶</a></h3>
<p>
  自动映射功能查找名为'rules.txt'在当前地图所在的文件夹中。此文本文件中的每一行是
</p>
<ul class="simple">
<li><strong>规则文件</strong>的路径</li>
<li>
  或指向另一个具有相同语法的文本文件的路径（即在另一个目录中）
</li>
<li>
  或是用<strong>#</strong>或 <strong>//</strong>表示的注释
</li>
</ul>
<p>
  <strong>规则文件</strong>是一个标准地图文件，可以通过tiled（*.tmx）读写。在一个规则文件中可以有多个已定义的规则。
</p>
<p>
  自动映射<strong>规则文件</strong>由4个主要部分组成：
</p>
<ol class="arabic simple">
<li>
  区域的定义描述了规则映射的哪些位置实际用于创建自动映射规则。
</li>
<li>
  输入的定义描述了将搜索工作地图的哪种模式。
</li>
<li>
  输出定义描述了在找到输入模式时如何更改工作地图。
</li>
<li>
  映射属性用于微调输入模式本地化和此规则文件中所有规则的输出。
</li>
</ol>
<div class="section" id="defining-the-regions">
<h4>定义区域<a class="headerlink" href="#defining-the-regions" title="Permalink to this headline">¶</a></h4>
<p>
  必须有一个称为<strong>regions</strong>的图块层，或者必须同时存在图块层<strong>regions_input</strong>和 <strong>regions_output</strong>。

  使用<strong>regions</strong>层，为输入和输出定义的区域是相同的。使用不同的层 <strong>regions_input</strong>和<strong>regions_output</strong>可以为输入部分和输出部分提供不同的区域。
  区域层仅用于标记存在自动映射规则的区域。
  因此，在这个层中使用哪个图块并不重要，因为这些图块只是用来定义一个区域。
  因此，在一个坐标处使用任何图块或不使用图块来指示该坐标是否属于规则。
</p>
<p>
  如果在一个规则映射文件中定义了多个规则，则区域不能相邻。
  这意味着两个规则之间必须至少有一个未使用的空间。如果这些区域是相邻的（相干的），那么这两个区域都被解释为一个规则。
</p>
<div class="section" id="multiple-rules-in-one-rulefile">
<h5>一个规则文件中有多个规则<a class="headerlink" href="#multiple-rules-in-one-rulefile" title="Permalink to this headline">¶</a></h5>
<p>
  一个规则映射中可以有多个规则。但是，如果希望以特定的顺序应用规则，则应使用多个<strong>规则文件</strong>并在 <strong>rules.txt</strong>文件。到目前为止，在一个rulemapfile中还有一个特定的序列。一般来说，y值较小的区域优先。如果存在相同y值的区域，则考虑x值。在正交地图上，这种排序方式与大多数西方国家的阅读方式相同（从左到右，从上到下）。一旦图块能够利用多个线程/处理器，一个规则映射中的顺序可以稍后更改。因此，如果您想依赖于某个序列，请使用不同的规则映射并在<strong>rules.txt</strong>。
 </p>
</div>
</div>
<div class="section" id="definition-of-inputs">
<h4>输入的定义<a class="headerlink" href="#definition-of-inputs" title="Permalink to this headline">¶</a></h4>
<p>
  输入通常由以下方案名称的图块层定义：
</p>
<p><strong>input[not][index]_name</strong></p>
<p>
  其中<strong>[not]</strong>和 <strong>[index]</strong>是可选的。在第一个下划线之后是输入层的名称。输入层名称当然可以包含更多的下划线。
</p>
<p>
  <strong>名称</strong>决定检查工作图上的哪一层。例如，图层input_Ground将检查工作图中名为Ground的图层，以获取此规则。 <em>input_test_case</em> 将检查此规则的工作地图中的图层<em>test_case</em>。
</p>
<p>
  索引用于创建完全不同的输入条件。在形成一个条件时，考虑具有相同索引的所有层。每种情况都要单独检查。
</p>
<ol class="arabic simple">
<li>索引不能包含下划线。</li>
<li>索引不能以<em>not</em>开头。</li>
<li>索引可能为空。</li>
</ol>
<p>
  如果标准输入层中有图块，则这些图块中必须有一个匹配规则。可选的<strong>[not]</strong> 反转该层的含义。因此，如果存在<strong>inputnot</strong>层，则放置在其上的分片不能出现在检查区域的工作地图中，以使规则匹配。在一个规则中，您可以将input和inputnot层的使用结合起来，使规则输入条件根据需要精确或模糊。
</p>
</div>
<div class="section" id="definition-of-outputs">
<h4>输出的定义<a class="headerlink" href="#definition-of-outputs" title="Permalink to this headline">¶</a></h4>
<p>
  输出通常由层定义，其名称如下所示：
</p>
<p><strong>output[index]_name</strong></p>
<p>
  这与输入部分非常相似。首先必须有输出这个词。然后可选地出现<strong>[index]</strong>。在第一个下划线之后是目标层的名称。目标层名称当然可以包含更多的下划线。
</p>
<p>
  同一索引的所有层都被视为一个可能的输出。因此，规则输出中的索引意图仅用于随机输出。
</p>
<p>
  输出部分中的索引与输入部分中的索引无关，它们是独立的。在输出部分，它们用于随机性。在输入部分，它们被用来定义多个可能的层作为输入。因此，当一个规则中有多个索引时，将公平地（均匀地）选择所有索引的输出。所以一个骰子将被掷骰子，并选出一个指数。所有携带此索引的输出层将被输出到工作地图中。
</p>
<p>
  请注意，不会检查输出本身是否重叠。这可以通过将映射属性<strong>NoOverlappingRules</strong>设置为true来实现。
</p>
</div>
<div class="section" id="map-properties">
<h4>地图属性<a class="headerlink" href="#map-properties" title="Permalink to this headline">¶</a></h4>
<p>
  以下地图属性可用于自定义<strong>规则文件</strong>中规则的行为：
</p>
<dl class="docutils">
<dt>DeleteTiles</dt>
<dd>
  此地图属性是布尔属性：它可以是true或false。
  如果在地图中的某个位置应用了此规则文件的规则，则此地图属性将确定在应用规则之前是否删除所有其他图块。考虑一个有多个图层的地图。并非所有层都在所有位置填充。在这种情况下，所有层的所有图块都应清除，因此之后只有规则定义的图块。因为之前并不是所有的图块都被清除了，所以在这些没有被任何图块覆盖的地方，仍然会有以前的图块。
  This map property is a boolean property: it can be
true or false.
 If rules of this rulefile get applied at some location
in your map, this map property determines if all other tiles are
deleted before applying the rules. Consider a map where you have
multiple layers. Not all layers are filled at all places. In that
case all tiles of all layers should be cleared, so afterwards there
are only the tiles which are defined by the rules. Since when not all
tiles are cleared before, you will have still tiles from before at
these places, which are not covered by any tile.</dd>
<dt>AutomappingRadius</dt>
<dd>
  此地图属性是一个数字：1、2、3…它决定了在实时自动映射时，将检查更改周围的分片数，以便重做自动映射。
</dd>
</dl>
<div class="new new-prev">Since Tiled 1.2</div><dl class="docutils">
<dt>MatchOutsideMap</dt>
<dd><p class="first">
  
  此地图属性确定规则是否可以匹配，即使其输入区域部分位于地图之外。默认情况下，对于有界地图为<code class="docutils literal notranslate"><span class="pre">false</span></code>，对于地图映射为<code class="docutils literal notranslate"><span class="pre">true</span></code>。在某些情况下，也可以对有界地图启用此功能。除非<strong>OverflowBorder</strong>或<strong>WrapBorder</strong>中的一个也为true，否则地图边界之外的分片将被视为空。
</p>
<p class="last">
  Tiled的1.0和1.1表现为此属性为<code class="docutils literal notranslate"><span class="pre">true</span></code>，而旧版本的Tiled则表现为此属性为<code class="docutils literal notranslate"><span class="pre">false</span></code>。
 </p>
</dd>
</dl>
<div class="new new-prev">Since Tiled 1.3</div><dl class="docutils">
<dt>OverflowBorder</dt>
<dd><p class="first">
  此地图属性自定义<strong>MatchOutsideMap</strong>属性预期的行为。当此属性为<code class="docutils literal notranslate"><span class="pre">true</span></code>时，地图边界以外的图块将被视为最近的入站分幅的副本，实际上会将地图边界“溢出”到外部区域。
  
  This map property customizes the behavior intended by the <strong>MatchOutsideMap</strong>
property. When this property is <code class="docutils literal notranslate"><span class="pre">true</span></code>, tiles outside of the map boundaries
are considered as if they were copies of the nearest inbound tiles, effectively
“overflowing” the map’s borders to the outside region.</p>
<p class="last">
  当此属性为<code class="docutils literal notranslate"><span class="pre">true</span></code>时，它表示MatchOutsideMap。注意，这个属性对无限映射没有影响（因为没有边界的概念）。
</p>
</dd>
</dl>
<div class="new new-prev">Since Tiled 1.3</div><dl class="docutils">
<dt>WrapBorder</dt>
<dd><p class="first">
  此地图属性自定义<strong>MatchOutsideMap</strong>属性预期的行为。当此属性为<code class="docutils literal notranslate"><span class="pre">true</span></code>时，贴图会有效地“环绕”自身，使贴图的一个边界上的分幅影响另一个边界上的区域，反之亦然。
  
</p>
<p>
  如果此属性为<code class="docutils literal notranslate"><span class="pre">true</span></code>，则表示<strong>MatchOutsideMap</strong>。请注意，此属性对无限地图无效（因为没有边界的概念）。
 </p>
<p class="last">
  如果<strong>WrapBorder</strong>和<strong>OverflowBorder</strong>都为<code class="docutils literal notranslate"><span class="pre">true</span></code>，则<strong>WrapBorder</strong>优先于 <strong>OverflowBorder</strong>。
 </p>
</dd>
<dt>NoOverlappingRules</dt>
<dd>
  此地图属性是一个布尔属性：不允许规则重叠。
</dd>
</dl>
<p>
  这些属性是地图范围的，这意味着它适用于规则地图一部分的所有规则。如果需要具有不同属性的规则，则可以使用多个规则地图。
</p>
</div>
<div class="section" id="layer-properties">
<h4>图层属性<a class="headerlink" href="#layer-properties" title="Permalink to this headline">¶</a></h4>
<p>
  每层支持以下属性：
 </p>
<dl class="docutils">
<dt>StrictEmpty</dt>
<dd><p class="first">
  该图层属性是一个布尔属性。可以将其添加到<strong>input</strong>和i<strong>inputnot</strong>图层，以自定义输入区域内空图块的行为。
</p>
<p class="last">
  在“ StrictEmpty”模式下，输入区域中的空白图块与设置图层中的空白图块匹配。因此，当“input”层在输入区域内包含一个空图块时，这意味着该位置处允许有一个空图块。而且，当“ inputnot”层在输入区域内包含一个空图块时，这意味着在该位置不允许有一个空图块。
 </p>
</dd>
</dl>
</div>
</div>
<div class="section" id="examples">
<h3>示例<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h3>
<div class="section" id="abstract-input-layer-examples">
<h4>抽象输入层示例<a class="headerlink" href="#abstract-input-layer-examples" title="Permalink to this headline">¶</a></h4>
<div class="section" id="having-multiple-input-layers-with-the-same-name">
<h5>
  具有相同名称的多个输入层
<a class="headerlink" href="#having-multiple-input-layers-with-the-same-name" title="Permalink to this headline">¶</a></h5>
<p>
  假设以下3个图块图层作为输入，工作图中有哪些可能的输入？
</p>
<table border="1" class="docutils">
<colgroup>
<col width="75%" />
<col width="25%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">图块层</th>
<th class="head">名字</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><img alt="tiles 1 and 2" class="first last" src="_images/12.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-odd"><td><img alt="tiles 3 and 4" class="first last" src="_images/34.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-even"><td><img alt="tiles 5 and 6" class="first last" src="_images/56.png" />
</td>
<td>input_Ground</td>
</tr>
</tbody>
</table>
<p>
  以下部分将被检测为与此规则匹配的部分:
</p>
<table border="1" class="docutils">
<colgroup>
<col width="35%" />
<col width="33%" />
<col width="32%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><img alt="tiles 1 and 2" class="first last" src="_images/12.png" />
</td>
<td><img alt="tiles 3 and 2" class="first last" src="_images/32.png" />
</td>
<td><img alt="tiles 5 and 2" class="first last" src="_images/52.png" />
</td>
</tr>
<tr class="row-even"><td><img alt="tiles 1 and 4" class="first last" src="_images/14.png" />
</td>
<td><img alt="tiles 3 and 4" class="first last" src="_images/34.png" />
</td>
<td><img alt="tiles 5 and 4" class="first last" src="_images/54.png" />
</td>
</tr>
<tr class="row-odd"><td><img alt="tiles 1 and 6" class="first last" src="_images/16.png" />
</td>
<td><img alt="tiles 3 and 6" class="first last" src="_images/36.png" />
</td>
<td><img alt="tiles 5 and 6" class="first last" src="_images/56.png" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="input-layers-using-different-indexes">
<h5>使用不同索引的输入层<a class="headerlink" href="#input-layers-using-different-indexes" title="Permalink to this headline">¶</a></h5>
<p>给定以下3个输入图块层：</p>
<table border="1" class="docutils">
<colgroup>
<col width="75%" />
<col width="25%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">图块层</th>
<th class="head">名称</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><img alt="tiles 1 and 2" class="first last" src="_images/12.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-odd"><td><img alt="tiles 3 and 4" class="first last" src="_images/34.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-even"><td><img alt="tiles 5 and 6" class="first last" src="_images/56.png" />
</td>
<td>input2_Ground</td>
</tr>
</tbody>
</table>
<p>
  最后一层的索引与其他索引（为空）不相等。以下所有部分都将被视为工作图中的匹配项：
</p>
<table border="1" class="docutils">
<colgroup>
<col width="51%" />
<col width="49%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><img alt="tiles 1 and 2" class="first last" src="_images/12.png" />
</td>
<td><img alt="tiles 3 and 2" class="first last" src="_images/32.png" />
</td>
</tr>
<tr class="row-even"><td><img alt="tiles 1 and 4" class="first last" src="_images/14.png" />
</td>
<td><img alt="tiles 3 and 4" class="first last" src="_images/34.png" />
</td>
</tr>
<tr class="row-odd"><td><img alt="tiles 5 and 6" class="first last" src="_images/56.png" />
</td>
<td>&#160;</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="the-mana-world-examples">
<h4>The Mana World Examples<a class="headerlink" href="#the-mana-world-examples" title="Permalink to this headline">¶</a></h4>
<p>
  “ Mana世界”示例将演示很多自动映射功能。首先，先添加所有笔直的部分，然后再构建一条海岸线，然后再修改规则以使它们也适合给定的图块，从而构建海岸线。添加海岸线后，对于游戏引擎，水域将被标记为不可行走。最后但并非最不重要的一点是，应使用5种不同的草砖将草砖随机化。
</p>
<div class="figure" id="id1">
<img alt="_images/before.png" src="_images/before.png" />
<p class="caption"><span class="caption-text">这就是我们要画的。</span></p>
</div>
<div class="figure" id="id2">
<img alt="_images/flow1.png" src="_images/flow1.png" />
<p class="caption"><span class="caption-text">在这里，我们应用了直线海岸线。</span></p>
</div>
<div class="figure" id="id3">
<img alt="_images/flow2.png" src="_images/flow2.png" />
<p class="caption"><span class="caption-text">这里有一些角。</span></p>
</div>
<div class="figure" id="id4">
<img alt="_images/flow3.png" src="_images/flow3.png" />
<p class="caption"><span class="caption-text">反之亦然。</span></p>
</div>
<div class="figure" id="id5">
<img alt="_images/flow4.png" src="_images/flow4.png" />
<p class="caption"><span class="caption-text">此处标记了所有不可行走的图块。</span></p>
</div>
<div class="figure" id="id6">
<img alt="_images/flow5.png" src="_images/flow5.png" />
<p class="caption"><span class="caption-text">如果您仔细观察一下草，就会发现它们现在是随机的了。</span></p>
</div>
<div class="section" id="basic-shoreline">
<h5>基本海岸线<a class="headerlink" href="#basic-shoreline" title="Permalink to this headline">¶</a></h5>
<p>
  此示例将演示如何在浅水草砖之间轻松设置直线海岸线。在此示例中，我们将仅实现海岸线，该海岸线南部为草皮，而北部为水。
</p>
<p>
  因此，基本上，我们将在输入区域中定义的含义是： <em>所有位于水瓦片以南且本身不是水瓦片的瓦片将由海岸线瓦片替换</em>
</p>
<table border="1" class="docutils">
<colgroup>
<col width="77%" />
<col width="23%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Tile layer</th>
<th class="head">Name</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><img alt="_images/regions.png" class="first last" src="_images/regions.png" />
</td>
<td>regions</td>
</tr>
<tr class="row-odd"><td><img alt="_images/input.png" class="first last" src="_images/input.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-even"><td><img alt="_images/output.png" class="first last" src="_images/output.png" />
</td>
<td>output_Ground</td>
</tr>
</tbody>
</table>
<p>
  应在其中定义此自动映射规则的区域为高2个图块，宽1个图块。因此，我们需要一个称为<em>regions</em>的图层，它将放置2个图块以指示该区域。
</p>
<p>
  中间描述了称为<em>input_Ground</em>的输入层。水砖仅填充上部瓦。下图块不包含图块。它不是看不见的图块，是没有图块。
 </p>
<p>
  并且，只要输入图层的规则区域内某位置没有图块，那将允许使用哪种瓷砖？除了所有输入层中具有相同索引和名称的所有已用图块外，所有图块都将被允许。
</p>
<p>
  在这里，我们只有一个图块层作为仅承载水图块的输入层。因此，在没有图块的位置，除水图块外所有图块都被允许。
  </p>
<p>
  如果此规则匹配，则称为<em>output_Ground</em>的输出层将显示放置的图块。
 </p>
</div>
<div class="section" id="corners-on-a-shore-line">
<h5>岸边的角落<a class="headerlink" href="#corners-on-a-shore-line" title="Permalink to this headline">¶</a></h5>
<p>
  此示例是先前示例的继续。现在，应该自动实现给定海岸线的拐角。在本文中，我们将仅检查左上角的弯角海岸线。其他海岸线拐角的建造方式相同。因此，在应用示例之后，我们希望使海岸线的拐角处获得合适的瓷砖。由于我们依赖于另一个示例的完成，因此我们将拐角所需的规则放入另一个新的规则文件中。 （之后在rules.txt中列出）
  
</p>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><img alt="_images/pattern1.png" class="first last" src="_images/pattern1.png" />
</td>
<td><img alt="_images/pattern2.png" class="first last" src="_images/pattern2.png" />
</td>
<td><img alt="_images/pattern3.png" class="first last" src="_images/pattern3.png" />
</td>
</tr>
<tr class="row-even"><td><img alt="_images/pattern4.png" class="first last" src="_images/pattern4.png" />
</td>
<td><img alt="_images/pattern5.png" class="first last" src="_images/pattern5.png" />
</td>
<td><img alt="_images/pattern6.png" class="first last" src="_images/pattern6.png" />
</td>
</tr>
<tr class="row-odd"><td><img alt="_images/pattern7.png" class="first last" src="_images/pattern7.png" />
</td>
<td><img alt="_images/pattern8.png" class="first last" src="_images/pattern8.png" />
</td>
<td><img alt="_images/pattern9.png" class="first last" src="_images/pattern9.png" />
</td>
</tr>
</tbody>
</table>
<p>
  海岸线附近可能有更多拐角，这意味着可能有比平直拐角线更多的砖块。在图中，我们看到了应涵盖的所有输入。
</p>
<p>右上角和左下角的图块都直接与左上角中的所需（略透明）图块相邻。</p>
<p>我们可以看到左下角有3个不同的图块，这是直的海岸线，向内弯曲和向外弯曲的海岸线。</p>
<p>我们还可以看到右上角有3种不同的输入，也可以是直的，弯入或弯出岸边线。</p>
<div class="section" id="regions">
<h6>regions<a class="headerlink" href="#regions" title="Permalink to this headline">¶</a></h6>
<p>因此，根据此规则，我们想将弯曲的岸线瓷砖放置在左上角，而不必关心之前的瓷砖。另外，我们也不关心右下角的图块。 （可能是水，也可以是任何装饰性的水图块，因此请忽略它）。</p>
<table border="1" class="docutils">
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="34%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><img alt="_images/regions_input.png" class="first last" src="_images/regions_input.png" />
</td>
<td><img alt="_images/regions_output.png" class="first last" src="_images/regions_output.png" />
</td>
<td><img alt="_images/regions_united.png" class="first last" src="_images/regions_united.png" />
</td>
</tr>
</tbody>
</table>
<p>
  因此，我们将需要不同的输入和输出区域。在图中，我们可以看到图块区域输入和区域输出。正如我们所讨论的，输入部分仅涵盖了这两个图块。输出区域仅覆盖我们要输出的单个图块。尽管输入和输出区域不重叠，但是输入和输出区域的统一区域仍然是一个相关区域，因此这是一条规则并且可以起作用。
  
</p>
<p>
  输出区域可以大于绝对需要的区域，因为当Output部分中没有图块时，工作地图中的图块不会被覆盖，而只是保持原样，因此Output区域的大小也可以设置为两个区域的合并区域的大小，既输出和输入区域。
</p>
</div>
<div class="section" id="regions-input">
<h6>regions_input<a class="headerlink" href="#regions-input" title="Permalink to this headline">¶</a></h6>
<p>
  现在我们要把我们观察到的九种可能的模式作为这个规则的可能输入。我们当然可以定义九个不同的层<em>input1_Ground</em>到<em>input9_Ground</em>。
</p>
<p>
  九个TileLayers ？！真是一团糟，我们会做一个更好的方法。
</p>
<p>
  另外，考虑在2个位置不仅有3个可能的图块，而是有4个。然后，我们将需要4 * 4 = 16个图块层来获取所有条件。另一个缺点是需要更多的位置：考虑构造规则输入需要两个以上的位置。因此，对于3个位置，每个位置可能具有3个可能性，因此您需要3 * 3 * 3 = 27个图块。情况并没有好转...
 </p>
<p>
  所以让我们尝试一种聪明的方法:所有的输入层都有相同的名称，这样在每个位置上三个不同的图块中的任何一个都是有效的。
</p>
<table border="1" class="docutils">
<colgroup>
<col width="80%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Tile layer</th>
<th class="head">Name</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><img alt="_images/input_Ground1.png" class="first last" src="_images/input_Ground1.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-odd"><td><img alt="_images/input_Ground2.png" class="first last" src="_images/input_Ground2.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-even"><td><img alt="_images/input_Ground3.png" class="first last" src="_images/input_Ground3.png" />
</td>
<td>input_Ground</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="outputs">
<h6>outputs<a class="headerlink" href="#outputs" title="Permalink to this headline">¶</a></h6>
<p>
  输出是直接的，因为只需要一个图块。不需要随机性，因此不需要更改索引，因此它保持为空。所需的输出层称为Ground，因此单个输出层的整体名称将output Ground。在此单层的正确位置上，放置了正确的图块。
  </p>
<table border="1" class="docutils">
<colgroup>
<col width="100%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><img alt="_images/output_Ground.png" class="first last" src="_images/output_Ground.png" />
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="the-other-corners-on-a-shore-line">
<h5>海岸线上的其他角落<a class="headerlink" href="#the-other-corners-on-a-shore-line" title="Permalink to this headline">¶</a></h5>
<p>这是针对以相反方向弯曲的拐角。基本上，它具有相同的概念，只是其他图块。</p>
<table border="1" class="docutils">
<colgroup>
<col width="78%" />
<col width="22%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Tile layer</th>
<th class="head">Name</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><img alt="_images/input_Ground11.png" class="first last" src="_images/input_Ground11.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-odd"><td><img alt="_images/input_Ground21.png" class="first last" src="_images/input_Ground21.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-even"><td><img alt="_images/input_Ground31.png" class="first last" src="_images/input_Ground31.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-odd"><td><img alt="_images/output_Ground1.png" class="first last" src="_images/output_Ground1.png" />
</td>
<td>output_Ground</td>
</tr>
<tr class="row-even"><td><img alt="_images/regions_input1.png" class="first last" src="_images/regions_input1.png" />
</td>
<td>regions_input</td>
</tr>
<tr class="row-odd"><td><img alt="_images/regions_output1.png" class="first last" src="_images/regions_output1.png" />
</td>
<td>regions_output</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="adding-collision-tiles">
<h5>添加碰撞块<a class="headerlink" href="#adding-collision-tiles" title="Permalink to this headline">¶</a></h5>
<p>
  
  《魔法世界》使用了一个额外的图块层（称为<em>Collision</em>）来获取有关玩家是否能够在某些图块上行走的信息。该层对于玩家是不可见的，但是无论是否有图块，游戏引擎都会对其进行解析。
</p>
<p>
  因此，我们需要确定每个位置是否可以让玩家走到那里，如果无法走动，请将一块图块放在<em>Collision</em>层中。
</p>
<p>
  作为<em>input</em>层，我们将分析<em>Ground</em>层，并将碰撞块放置在玩家不应行走的地方。
  
</p>
<p>
  实际上，此任务是一堆规则，但是每个规则本身都很简单：
</p>
<table border="1" class="docutils">
<colgroup>
<col width="77%" />
<col width="23%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Tile layer</th>
<th class="head">Name</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><img alt="_images/regions1.png" class="first last" src="_images/regions1.png" />
</td>
<td>regions</td>
</tr>
<tr class="row-odd"><td><img alt="_images/input_Ground.png" class="first last" src="_images/input_Ground.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-even"><td><img alt="_images/output_Collision.png" class="first last" src="_images/output_Collision.png" />
</td>
<td>output_Collision</td>
</tr>
</tbody>
</table>
<p>
  在上述<em>regions</em> 层中，我们有14个不同的规则，因为在<em>regions</em> 层中有14个非相干区域。那是9种不同的水图块，它们不能走动，还有5种不同的草图块，将在下一个示例中随机放置。
 </p>
<p>
  作为输入，我们将拥有所有使用的图块之一，而作为输出，则是在<em>Collision</em>层中是否存在图块。
</p>
<p>
  <strong> 我们需要干净输出的规则吗？</strong>不，一次运行自动映射不需要它。（ No, it is not needed for one
  run of Automapping.）但是，如果要设计地图，则可能会添加有冲突的区域，然后再次删除其中的某些部分，依此类推。
</p>
<p>
  因此，我们还需要从不再有碰撞标记的位置移除碰撞块。这可以通过添加地图属性<em>DeleteTiles</em>并将其设置为<em>yes</em>或<em>true</em>来完成。然后，在进行自动映射之前，将清除<em>Collision</em>层中的所有零件，因此仅将碰撞块放置在真正的不可行走的块上，而忽略是否放置了碰撞块的历史记录。
 </p>
</div>
<div class="section" id="random-grass-tiles">
<h5>随机草地图块<a class="headerlink" href="#random-grass-tiles" title="Permalink to this headline">¶</a></h5>
<p>
  在此示例中，我们将对所有草地图块进行洗牌，因此将一个草地图块替换为另一个随机选择的草地图块。
</p>
<p>
  作为输入，我们将选择所有草地图块。这是通过将每个图块放置在其自己的输入层中来完成的，因此每个草砖都将被该规则接受。
</p>
<p>
  作为输出，我们还将每个草地图块放到一个输出层中。为了使其随机，输出层的<em>索引</em>对于每一层都需要不同。
</p>
<p>
  下面的规则看起来可能是一样的，但是有不同的草瓷砖。每个草砖都在一个输入层和一个输出层中(层的顺序无关紧要)。
 </p>
<table border="1" class="docutils">
<colgroup>
<col width="81%" />
<col width="19%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Tile layer</th>
<th class="head">Name</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><img alt="_images/regions2.png" class="first last" src="_images/regions2.png" />
</td>
<td>regions</td>
</tr>
<tr class="row-odd"><td><img alt="_images/1.png" class="first last" src="_images/1.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-even"><td><img alt="_images/2.png" class="first last" src="_images/2.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-odd"><td><img alt="_images/3.png" class="first last" src="_images/3.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-even"><td><img alt="_images/4.png" class="first last" src="_images/4.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-odd"><td><img alt="_images/5.png" class="first last" src="_images/5.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-even"><td><img alt="_images/1.png" class="first last" src="_images/1.png" />
</td>
<td>output1_Ground</td>
</tr>
<tr class="row-odd"><td><img alt="_images/2.png" class="first last" src="_images/2.png" />
</td>
<td>output2_Ground</td>
</tr>
<tr class="row-even"><td><img alt="_images/3.png" class="first last" src="_images/3.png" />
</td>
<td>output3_Ground</td>
</tr>
<tr class="row-odd"><td><img alt="_images/4.png" class="first last" src="_images/4.png" />
</td>
<td>output4_Ground</td>
</tr>
<tr class="row-even"><td><img alt="_images/5.png" class="first last" src="_images/5.png" />
</td>
<td>output5_Ground</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="an-alternating-wall">
<h4>一个交替的墙<a class="headerlink" href="#an-alternating-wall" title="Permalink to this headline">¶</a></h4>
<p>  此示例将演示如何轻松设置在可步行区域和不可步行的黑色空隙之间过渡的墙。作为输入，将使用专用的设置层。</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><img alt="Vertically the tiles are alternating" class="first last" src="_images/desired.png" />
</td>
<td><img alt="A dedicated set layer" class="first last" src="_images/setlayer.png" />
</td>
</tr>
</tbody>
</table>
<p>

  在我看来，专用的固定层更容易用于粗略的草稿，但是要在装饰瓷砖上添加诸如碰撞信息之类的细节，输入应使用装饰。
 </p>
<p>
  输入，输出和区域层的结构与《魔法世界》示例中的直线海岸线示例非常相似。主要区别在于大小不同。由于墙的高度包含多个图块，因此规则图层的高度也不同。垂直方向上的图块也交替出现。如您在下图中所看到的，例如，显示墙的基板的每隔一个图块都有一个凹口。
</p>
<table border="1" class="docutils">
<colgroup>
<col width="78%" />
<col width="22%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Tile layer</th>
<th class="head">Name</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><img alt="_images/regions3.png" class="first last" src="_images/regions3.png" />
</td>
<td>regions</td>
</tr>
<tr class="row-odd"><td><img alt="_images/input_Ground4.png" class="first last" src="_images/input_Ground4.png" />
</td>
<td>input_Ground</td>
</tr>
<tr class="row-even"><td><img alt="_images/output_Ground2.png" class="first last" src="_images/output_Ground2.png" />
</td>
<td>output_Walls</td>
</tr>
</tbody>
</table>
<p>
  因此，应在其中定义此自动映射规则的区域的高度为4个图块，宽度为2个图块。因此，我们需要一个称为<em>regions</em>的图层，它将放置8个图块以指示该区域。在图中，顶部图形显示了这样的区域层。
 </p>
<p>输入层的含义如下：</p>
<p><em>
  如果在设置层中有2个垂直相邻的棕色图块，并且在上面的3x2瓷砖中没有棕色图块，则此规则匹配。
  </em></p>
<p>
  只有最低的2个坐标包含棕色图块。上面的坐标不包含图块。(它不是隐形的瓦，只是根本没有瓦。)名为<em>Input_set</em>的输入层如图中间所示。
 </p>
<p>
  输出只包含一个称为<em>Output_Walls</em>的层。它包含实际的墙砖。
</p>
<div class="figure" id="id7">
<img alt="_images/desired.png" src="_images/desired.png" />
<p class="caption"><span class="caption-text">Vertically the tiles are alternating.</span></p>
</div>
<div class="figure" id="id8">
<img alt="_images/firstattempt.png" src="_images/firstattempt.png" />
<p class="caption"><span class="caption-text">
  规则的无效版本，因为尚未设置<em>NoOverlappingRules</em>。
  </span></p>
</div>
<p>
  尝试将输入层与所需的设置层进行匹配时（示例开头的右图），您将看到它一直匹配，而无需进行垂直调整。
</p>
<p>
  因此，当我们使用现在讨论的规则时，由于该规则自身重叠，因此不会获得预期的结果。重叠的问题如上图所示。
</p>
<p>
  由于不需要重叠，我们可以通过将map属性<em>NoOverlappingRules</em>添加到rulemap并将其设置为<em>true</em>来将其关闭
</p>
<p>请记住，map属性适用于该规则映射上的所有规则。</p>
</div>
</div>
</div>
<span id="document-manual/export"></span><div class="section" id="export-formats">
<h2>输出格式<a class="headerlink" href="#export-formats" title="Permalink to this headline">¶</a></h2>
<p>
  虽然有许多<a class="reference internal" href="index.html#document-reference/support-for-tmx-maps"><span class="doc">库和框架</span></a>可以直接使用Tiled地图，但Tiled还支持许多其他文件和导出格式，以及<a class="reference internal" href="#export-as-image"><span class="std std-ref">将地图导出到图像</span></a>。
</p>
<p>
  可以通过单击<em>文件 &gt; 导出</em>完成导出。当多次触发菜单动作时，Tiled只会在第一次询问文件名。还可以使用<code class="docutils literal notranslate"><span class="pre">--export-map</span></code>和<code class="docutils literal notranslate"><span class="pre">--export-tileset</span></code>命令行参数自动导出。
</p>
<p>
  提供了几个<a class="reference internal" href="index.html#export-options"><span class="std std-ref">导出选项</span></a>，这些选项在导出之前会应用于地图或图块（不影响地图或图块本身）。
</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>
  在Linux上的命令行上导出时，Tiled仍将需要X服务器来运行。要在无头环境中自动执行导出，可以使用无头X服务器，例如Xvfb。在这种情况下，您可以从命令行运行Tiled，如下所示：
  When exporting on the command-line on Linux, Tiled will still need an
X server to run. To automate exports in a headless environment, you
can use a headless X server such as <a class="reference external" href="https://www.x.org/archive/X11R7.6/doc/man/man1/Xvfb.1.xhtml">Xvfb</a>. In this case you would
run Tiled from the command-line as follows:</p>
<div class="last highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">xvfb</span><span class="o">-</span><span class="n">run</span> <span class="n">tiled</span> <span class="o">--</span><span class="n">export</span><span class="o">-</span><span class="nb">map</span> <span class="o">...</span>
</pre></div>
</div>
</div>
<div class="section" id="json">
<h3>JSON<a class="headerlink" href="#json" title="Permalink to this headline">¶</a></h3>
<p>
  <a class="reference internal" href="index.html#document-reference/json-map-format"><span class="doc">JSON格式</span></a>是Tiled支持的最常见的附加文件格式。它可以代替TMX使用，因为Tiled也可以打开JSON地图和图块集，并且格式支持所有Tiled功能。特别是在浏览器中以及通常使用JavaScript时，JSON格式更易于加载。
</p>
<p>JSON格式是当前惟一支持图块集的附加格式。</p>
</div>
<div class="section" id="lua">
<span id="lua-export"></span><h3>Lua<a class="headerlink" href="#lua" title="Permalink to this headline">¶</a></h3>
<p>
  可以将地图和图块集导出为Lua代码。此导出选项支持Tiled的大多数功能，在使用基于Lua的框架（如<a class="reference external" href="https://love2d.org/">LÖVE</a>（具有<a class="reference external" href="https://github.com/karai17/Simple-Tiled-Implementation">Simple Tiled Implementation</a>）， <a class="reference external" href="https://coronalabs.com/">Corona</a>（具有<a class="reference external" href="https://github.com/ponywolf/ponytiled">ponytiled</a> 或<a class="reference external" href="https://github.com/GymbylCoding/Dusk-Engine">Dusk Engine</a>）或<a class="reference external" href="https://www.defold.com/">Defold</a>时非常有用。
</p>
<p>
  当前不包括自定义属性的类型（尽管该类型确实会影响属性值的导出方式）以及与诸如<a class="reference internal" href="index.html#document-manual/using-wang-tiles"><span class="doc">王氏图块</span></a>和<a class="reference internal" href="index.html#document-manual/using-templates"><span class="doc">对象模板</span></a>之类的最新功能有关的信息。
</p>
</div>
<div class="section" id="csv">
<h3>CSV<a class="headerlink" href="#csv" title="Permalink to this headline">¶</a></h3>
<p>
  CSV导出仅支持<a class="reference internal" href="index.html#document-manual/editing-tile-layers"><span class="doc">图块层</span></a>。包含多个图块图层的地图将导出为多个文件，称为<code class="docutils literal notranslate"><span class="pre">base_&lt;layer-name&gt;.csv</span></code>。
</p>
<p>
  除非图块具有名为<code class="docutils literal notranslate"><span class="pre">name</span></code>的自定义属性，否则每个图块均通过其ID进行写出，在这种情况下，其值将用于写出图块。除非使用自定义名称属性，否则使用多个图块集将导致ID模棱两可。空单元格的值为<code class="docutils literal notranslate"><span class="pre">-1</span></code>。
</p>
</div>
<div class="section" id="gamemaker-studio-1-4">
<span id="gamemaker-export"></span><h3>GameMaker: Studio 1.4<a class="headerlink" href="#gamemaker-studio-1-4" title="Permalink to this headline">¶</a></h3>
<p>
  GameMaker：Studio 1.4使用基于XML的自定义格式来存储其房间，Tiled附带了一个插件，用于以这种格式导出地图。当前，只有正交贴图可以正确导出。
</p>
<p>
  图块图层和图块对象（未设置类型时）将导出为“tile”元素。这些支持水平和垂直翻转，但不旋转。对于图块对象，还支持缩放。
</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">
  图块集的名称必须与GameMaker项目中的相应背景相同。否则，GameMaker在加载导出的<code class="docutils literal notranslate"><span class="pre">room.gmx</span></code>文件时将为每个图块弹出一个错误。
 </p>
</div>
<div class="section" id="object-instances">
<h4>Object Instances<a class="headerlink" href="#object-instances" title="Permalink to this headline">¶</a></h4>
<p>GameMaker object instances are created by putting the object name in the
“Type” field of the object in Tiled. Rotation is supported here, and for
tile objects also flipping and scaling is supported (though flipping in
combination with rotation doesn’t appear to work in GameMaker).</p>
<div class="new new-prev">Since Tiled 1.1</div><p>The following custom properties can be set on objects to affect the
exported instance:</p>
<ul class="simple">
<li>string <code class="docutils literal notranslate"><span class="pre">code</span></code> (instance creation code, default: “”)</li>
<li>float <code class="docutils literal notranslate"><span class="pre">scaleX</span></code> (default: derived from tile or 1.0)</li>
<li>float <code class="docutils literal notranslate"><span class="pre">scaleY</span></code> (default: derived from tile or 1.0)</li>
<li>int <code class="docutils literal notranslate"><span class="pre">originX</span></code> (default: 0)</li>
<li>int <code class="docutils literal notranslate"><span class="pre">originY</span></code> (default: 0)</li>
</ul>
<p>The <code class="docutils literal notranslate"><span class="pre">scaleX</span></code> and <code class="docutils literal notranslate"><span class="pre">scaleY</span></code> properties can be used to override the
scale of the instance. However, if the scale is relevant then it will
generally be easier to use a tile object, in which case it is
automatically derived from the tile size and the object size.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">originX</span></code> and <code class="docutils literal notranslate"><span class="pre">originY</span></code> properties can be used to tell Tiled
about the origin of the object defined in GameMaker, as an offset from
the top-left. This origin is taken into account when determining the
position of the exported instance.</p>
<div class="admonition hint">
<p class="first admonition-title">Hint</p>
<p class="last">Of course setting the type and/or the above properties manually for
each instance will get old fast. Since Tiled 1.0.2, you can instead
use tile objects with the type set on the tile, and in Tiled 1.1 you
can also use <a class="reference internal" href="index.html#document-manual/using-templates"><span class="doc">object templates</span></a>.</p>
</div>
<div class="new new-prev">Since Tiled 1.1</div></div>
<div class="section" id="views">
<h4>Views<a class="headerlink" href="#views" title="Permalink to this headline">¶</a></h4>
<div class="figure align-right">
<img alt="GameMaker View Settings" src="_images/gamemaker-view-settings.png" />
</div>
<p>Views can be defined using <a class="reference internal" href="index.html#insert-rectangle-tool"><span class="std std-ref">rectangle objects</span></a>
where the Type has been set to <code class="docutils literal notranslate"><span class="pre">view</span></code>. The position and size will be
snapped to pixels. Whether the view is visible when the room starts
depends on whether the object is visible. The use of views is
automatically enabled when any views are defined.</p>
<p>The following custom properties can be used to define the various other
properties of the view:</p>
<p><strong>Port on screen</strong></p>
<ul class="simple">
<li>int <code class="docutils literal notranslate"><span class="pre">xport</span></code> (default: 0)</li>
<li>int <code class="docutils literal notranslate"><span class="pre">yport</span></code> (default: 0)</li>
<li>int <code class="docutils literal notranslate"><span class="pre">wport</span></code> (default: 1024)</li>
<li>int <code class="docutils literal notranslate"><span class="pre">hport</span></code> (default: 768)</li>
</ul>
<p><strong>Object following</strong></p>
<ul class="simple">
<li>string <code class="docutils literal notranslate"><span class="pre">objName</span></code></li>
<li>int <code class="docutils literal notranslate"><span class="pre">hborder</span></code> (default: 32)</li>
<li>int <code class="docutils literal notranslate"><span class="pre">vborder</span></code> (default: 32)</li>
<li>int <code class="docutils literal notranslate"><span class="pre">hspeed</span></code> (default: -1)</li>
<li>int <code class="docutils literal notranslate"><span class="pre">vspeed</span></code> (default: -1)</li>
</ul>
<div class="admonition hint">
<p class="first admonition-title">Hint</p>
<p class="last">When you’re defining views in Tiled, it is useful to add <code class="docutils literal notranslate"><span class="pre">view</span></code>
as object type in the <a class="reference internal" href="index.html#predefining-properties"><span class="std std-ref">Object Types Editor</span></a>,
adding the above properties for ease of access. If you frequently use
views with similar settings, you can set up
<a class="reference internal" href="index.html#document-manual/using-templates"><span class="doc">templates</span></a> for them.</p>
</div>
</div>
<div class="section" id="map-properties">
<h4>Map Properties<a class="headerlink" href="#map-properties" title="Permalink to this headline">¶</a></h4>
<div class="section" id="general">
<h5>General<a class="headerlink" href="#general" title="Permalink to this headline">¶</a></h5>
<ul class="simple">
<li>int <code class="docutils literal notranslate"><span class="pre">speed</span></code> (default: 30)</li>
<li>bool <code class="docutils literal notranslate"><span class="pre">persistent</span></code> (default: false)</li>
<li>bool <code class="docutils literal notranslate"><span class="pre">clearDisplayBuffer</span></code> (default: true)</li>
<li>bool <code class="docutils literal notranslate"><span class="pre">clearViewBackground</span></code> (default: false)</li>
<li>string <code class="docutils literal notranslate"><span class="pre">code</span></code> (map creation code, default: “”)</li>
</ul>
</div>
<div class="section" id="physics">
<h5>Physics<a class="headerlink" href="#physics" title="Permalink to this headline">¶</a></h5>
<ul class="simple">
<li>bool <code class="docutils literal notranslate"><span class="pre">PhysicsWorld</span></code> (default: false)</li>
<li>int <code class="docutils literal notranslate"><span class="pre">PhysicsWorldTop</span></code> (default: 0)</li>
<li>int <code class="docutils literal notranslate"><span class="pre">PhysicsWorldLeft</span></code> (default: 0)</li>
<li>int <code class="docutils literal notranslate"><span class="pre">PhysicsWorldRight</span></code> (default: width of map in pixels)</li>
<li>int <code class="docutils literal notranslate"><span class="pre">PhysicsWorldBottom</span></code> (default: height of map in pixels)</li>
<li>float <code class="docutils literal notranslate"><span class="pre">PhysicsWorldGravityX</span></code> (default: 0.0)</li>
<li>float <code class="docutils literal notranslate"><span class="pre">PhysicsWorldGravityY</span></code> (default: 10.0)</li>
<li>float <code class="docutils literal notranslate"><span class="pre">PhysicsWorldPixToMeters</span></code> (default: 0.1)</li>
</ul>
</div>
</div>
<div class="section" id="layer-properties">
<h4>Layer Properties<a class="headerlink" href="#layer-properties" title="Permalink to this headline">¶</a></h4>
<p>Both tile layers and object layers may produce “tile” elements in the exported
room file. Their depth is set automatically, with tiles from the bottom-most
layer getting a value of 10000000 (the GameMaker default) and counting up from
there. If you want to set a custom depth value you can set the following
property on the layer:</p>
<ul class="simple">
<li>int <code class="docutils literal notranslate"><span class="pre">depth</span></code> (default: 10000000 + N)</li>
</ul>
<div class="new new-prev">Since Tiled 1.1</div></div>
</div>
<div class="section" id="tbin">
<h3>tBIN<a class="headerlink" href="#tbin" title="Permalink to this headline">¶</a></h3>
<p>The tBIN map format is a binary format used by the <a class="reference external" href="https://colinvella.github.io/tIDE/">tIDE Tile Map Editor</a>.
tIDE was used by <a class="reference external" href="https://stardewvalley.net/">Stardew Valley</a>, a successful game that spawned many
<a class="reference external" href="https://www.nexusmods.com/stardewvalley/?">community mods</a>.</p>
<p>Tiled ships with a plugin that enables direct editing of Stardew Valley
maps (and any other maps using the tBIN format). This plugin needs to be
enabled in <em>Edit &gt; Preferences &gt; Plugins</em>. It is not enabled by default
because it won’t store everything (most notably it doesn’t support
object layers in general, nor external tilesets), so you need to know
what you are doing.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The tBIN format supports setting custom properties on the tiles of a
tile layer. Since Tiled does not support this directly, “TileData”
objects are created that match the location of the tile, on which
such properties are then stored.</p>
</div>
</div>
<div class="section" id="defold">
<h3>Defold<a class="headerlink" href="#defold" title="Permalink to this headline">¶</a></h3>
<p>Tiled can export to Defold using one of the two supplied plugins. Both are
disabled by default.</p>
<p><strong>defold</strong></p>
<p>This plugin exports a map to a <a class="reference external" href="https://www.defold.com/manuals/tilemap/">Defold Tile Map</a> (*.tilemap).
It only supports tile layers and only a single tileset may be used.</p>
<p>Upon export, the <code class="docutils literal notranslate"><span class="pre">tile_set</span></code> property of the Tile Map is left empty, so it
will need to be set up in Defold after each export.</p>
<p><strong>defoldcollection</strong></p>
<p>This plugin exports a map to a <a class="reference external" href="https://www.defold.com/manuals/building-blocks/">Defold Collection</a> (*.collection), while
also creating multiple .tilemap files.</p>
<p>It supports:</p>
<ul class="simple">
<li>Group layers (<strong>only top-level group layers are supported, not nested ones!</strong>)</li>
<li>Multiple Tilesets per Tilemap</li>
</ul>
<p>Upon export:</p>
<ul class="simple">
<li>The <code class="docutils literal notranslate"><span class="pre">Path</span></code> property of each Tileset may need to be set up manually in
Defold after each export. However, Tiled will attempt to find the
.tilesource file corresponding with the name your Tileset in Tiled in your
project’s <code class="docutils literal notranslate"><span class="pre">/tilesources/</span></code> directory. If one is found, manual adjustments
won’t be necessary.</li>
<li>If you create custom properties on your map called <code class="docutils literal notranslate"><span class="pre">x-offset</span></code> and
<code class="docutils literal notranslate"><span class="pre">y-offset</span></code>, these values will be used as coordinates for your top-level
GameObject in the Collection. This is useful when working with <a class="reference internal" href="index.html#document-manual/worlds"><span class="doc">Worlds</span></a>.</li>
</ul>
<p>All layers of a Tilemap will have Z-index property assigned with values
ranging between 0 and 0.1. The plugin supports the use of 9999 Group Layers
and 9999 Tile Layers per Group Layer.</p>
<p>When any additional information from the map is needed, the map can be
exported in <a class="reference internal" href="#lua-export"><span class="std std-ref">Lua format</span></a> and loaded as Defold script.</p>
</div>
<div class="section" id="other-formats">
<h3>Other Formats<a class="headerlink" href="#other-formats" title="Permalink to this headline">¶</a></h3>
<p>A few other plugins ship with Tiled to support various games:</p>
<dl class="docutils">
<dt>droidcraft</dt>
<dd>Adds support for editing <a class="reference external" href="https://play.google.com/store/apps/details?id=org.me.droidcraft">DroidCraft</a> maps (*.dat)</dd>
<dt>flare</dt>
<dd>Adds support for editing <a class="reference external" href="http://flarerpg.org/">Flare Engine</a> maps (*.txt)</dd>
<dt>replicaisland</dt>
<dd>Adds support for editing <a class="reference external" href="http://replicaisland.net/">Replica Island</a> maps (*.bin)</dd>
<dt>tengine</dt>
<dd>Adds support for exporting to <a class="reference external" href="https://te4.org/te4">T-Engine4</a> maps (*.lua)</dd>
</dl>
<p>These plugins are disabled by default. They can be enabled in <em>Edit &gt; Preferences &gt; Plugins</em>.</p>
<div class="section" id="javascript">
<h4>JavaScript<a class="headerlink" href="#javascript" title="Permalink to this headline">¶</a></h4>
<p>It is possible to add custom export formats using <a class="reference internal" href="index.html#document-reference/scripting"><span class="doc">scripting</span></a> (by calling <a class="reference internal" href="index.html#script-registermapformat"><span class="std std-ref">tiled.registerMapFormat</span></a> or <a class="reference internal" href="index.html#script-registertilesetformat"><span class="std std-ref">tiled.registerTilesetFormat</span></a>).</p>
</div>
<div class="section" id="python-scripts">
<h4>Python Scripts<a class="headerlink" href="#python-scripts" title="Permalink to this headline">¶</a></h4>
<p>It is also possible to write <a class="reference internal" href="index.html#document-manual/python"><span class="doc">Python scripts</span></a> to add
support for importing or exporting custom map formats.</p>
</div>
</div>
<div class="section" id="export-as-image">
<span id="id1"></span><h3>Export as Image<a class="headerlink" href="#export-as-image" title="Permalink to this headline">¶</a></h3>
<p>Maps can be exported as image. Tiled supports most common image formats.
Choose <em>File -&gt; Export as Image…</em> to open the relevant dialog.</p>
<p>Since exporting a map can in some cases result in a huge image, a <em>Use current
zoom level</em> option is provided to allow exporting the map at the size it’s
currently displayed at.</p>
<p>For repeatedly converting a map to an image, manually triggering this export
isn’t very convenient. For this purpose, a tool called <code class="docutils literal notranslate"><span class="pre">tmxrasterizer</span></code> ships
with Tiled, which contrary to its name is able to render any supported map
format to an image. It is also able to render <a class="reference internal" href="index.html#document-manual/worlds"><span class="doc">entire worlds</span></a> to
an image. On Linux this tool can be set up for generating thumbnail previews
of maps in the file manager.</p>
</div>
</div>
<span id="document-manual/keyboard-shortcuts"></span><div class="section" id="keyboard-shortcuts">
<h2>Keyboard Shortcuts<a class="headerlink" href="#keyboard-shortcuts" title="Permalink to this headline">¶</a></h2>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Most of the below shortcuts can be changed in the <a class="reference internal" href="index.html#keyboard-options"><span class="std std-ref">Preferences</span></a>.</p>
</div>
<p>On Mac, replace <code class="docutils literal notranslate"><span class="pre">Ctrl</span></code> with the <code class="docutils literal notranslate"><span class="pre">Command</span></code> key.</p>
<div class="section" id="general">
<h3>General<a class="headerlink" href="#general" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">Right</span> <span class="pre">Click</span> <span class="pre">on</span> <span class="pre">Tile</span></code> - Captures the tile under the mouse (drag to
capture larger areas).</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">MouseWheel</span></code> - Zoom in/out on tileset and map</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Plus/Minus</span></code> - Zoom in/out on map</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">0</span></code> - Reset zoom on map</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Object</span> <span class="pre">Move</span></code> - Toggles “Snap to Grid” temporarily</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Object</span> <span class="pre">Resize</span></code> - Keep aspect ratio</li>
<li><code class="docutils literal notranslate"><span class="pre">Alt</span> <span class="pre">+</span> <span class="pre">Object</span> <span class="pre">Resize</span></code> - Toggles “Snap to Grid” temporarily</li>
<li><code class="docutils literal notranslate"><span class="pre">Middle</span> <span class="pre">Click</span></code> or <code class="docutils literal notranslate"><span class="pre">Space</span> <span class="pre">Bar</span></code> - Hold to pan the map view</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">X</span></code> - Cut (tiles, objects or properties)</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">C</span></code> - Copy (tiles, objects or properties)</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">V</span></code> - Paste (tiles, objects or properties)</li>
<li><code class="docutils literal notranslate"><span class="pre">Del</span></code> - Delete (tiles or objects)</li>
<li><code class="docutils literal notranslate"><span class="pre">H</span></code> - Toggle highlighting of the current layer</li>
<li><code class="docutils literal notranslate"><span class="pre">A</span></code> - Invokes <a class="reference internal" href="index.html#document-manual/automapping"><span class="doc">Automapping</span></a></li>
<li><code class="docutils literal notranslate"><span class="pre">Alt</span> <span class="pre">+</span> <span class="pre">C</span></code> - Copy current position of mouse cursor to clipboard (in
tile coordinates)</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">D</span></code> - Duplicate selected objects</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">D</span></code> - Duplicate active layer</li>
<li><code class="docutils literal notranslate"><span class="pre">F2</span></code> - Rename (if applicable in context)</li>
<li><code class="docutils literal notranslate"><span class="pre">Tab</span></code> - Hide docks and tool bars</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">PgUp</span></code> - Select previous layer (above current layer)</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">PgDown</span></code> - Select next layer (below current layer)</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">Up</span></code> - Move current layer up</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">Down</span></code> - Move current layer down</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">H</span></code> - Show/Hide all other layers (only active layer
visible / all layers visible)</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Tab</span></code> - Switch to left document</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">Tab</span></code> - Switch to right document</li>
<li><code class="docutils literal notranslate"><span class="pre">Alt</span> <span class="pre">+</span> <span class="pre">Left</span></code> - Switch to left document</li>
<li><code class="docutils literal notranslate"><span class="pre">Alt</span> <span class="pre">+</span> <span class="pre">Right</span></code> - Switch to right document</li>
<li><code class="docutils literal notranslate"><span class="pre">]</span></code> - Select next tileset</li>
<li><code class="docutils literal notranslate"><span class="pre">[</span></code> - Select previous tileset</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">G</span></code> - Toggle displaying of the tile grid</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">W</span></code> - Close current document</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">W</span></code> - Close all documents</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">E</span></code> - Export current document</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">E</span></code> - Export current document to another file</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Q</span></code> - Quit Tiled</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">R</span></code> - Reload current document</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">T</span></code> - Force-reload all tilesets used by the current map
(mainly useful when not using the automatic reloading)</li>
</ul>
</div>
<div class="section" id="when-a-tile-layer-is-selected">
<h3>When a tile layer is selected<a class="headerlink" href="#when-a-tile-layer-is-selected" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">D</span></code> - Toggle Random Mode</li>
<li><code class="docutils literal notranslate"><span class="pre">B</span></code> - Activate <a class="reference internal" href="index.html#stamp-tool"><span class="std std-ref">Stamp Brush</span></a><ul>
<li><code class="docutils literal notranslate"><span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">Click</span></code> - Line mode, places tiles on a line between two
clicked locations</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">Click</span></code> - Circle mode, places tiles around the
clicked center</li>
</ul>
</li>
<li><code class="docutils literal notranslate"><span class="pre">T</span></code> - Activate <a class="reference internal" href="index.html#terrain-tool"><span class="std std-ref">Terrain Brush</span></a></li>
<li><code class="docutils literal notranslate"><span class="pre">G</span></code> - Activate <a class="reference internal" href="index.html#wang-tool"><span class="std std-ref">Wang Brush</span></a> (since Tiled 1.1)</li>
<li><code class="docutils literal notranslate"><span class="pre">F</span></code> - Activate <a class="reference internal" href="index.html#bucket-fill-tool"><span class="std std-ref">Bucket Fill Tool</span></a></li>
<li><code class="docutils literal notranslate"><span class="pre">P</span></code> - Activate <a class="reference internal" href="index.html#shape-fill-tool"><span class="std std-ref">Shape Fill Tool</span></a></li>
<li><code class="docutils literal notranslate"><span class="pre">E</span></code> - Activate <a class="reference internal" href="index.html#eraser-tool"><span class="std std-ref">Eraser</span></a></li>
<li><code class="docutils literal notranslate"><span class="pre">R</span></code> - Activate Rectangular Select</li>
<li><code class="docutils literal notranslate"><span class="pre">W</span></code> - Activate Magic Wand</li>
<li><code class="docutils literal notranslate"><span class="pre">S</span></code> - Activate Select Same Tile</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">1-9</span></code> - Store current tile selection (similar to
<code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">C</span></code>)</li>
<li><code class="docutils literal notranslate"><span class="pre">1-9</span></code> recall the previous selection (similar to <code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">V</span></code>)</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">A</span></code> - Select the whole layer</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">A</span></code> - Select nothing</li>
</ul>
<p>Changing the active stamp:</p>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">X</span></code> - Flip active stamp horizontally</li>
<li><code class="docutils literal notranslate"><span class="pre">Y</span></code> - Flip active stamp vertically</li>
<li><code class="docutils literal notranslate"><span class="pre">Z</span></code> - Rotate active stamp clockwise</li>
<li><code class="docutils literal notranslate"><span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">Z</span></code> - Rotate active stamp counterclockwise</li>
</ul>
</div>
<div class="section" id="when-an-object-layer-is-selected">
<h3>When an object layer is selected<a class="headerlink" href="#when-an-object-layer-is-selected" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">S</span></code> - Activate <a class="reference internal" href="index.html#select-objects-tool"><span class="std std-ref">Select Objects</span></a><ul>
<li><code class="docutils literal notranslate"><span class="pre">PgUp</span></code> - Raise selected objects (with Manual object drawing
order)</li>
<li><code class="docutils literal notranslate"><span class="pre">PgDown</span></code> - Lower selected objects (with Manual object drawing
order)</li>
<li><code class="docutils literal notranslate"><span class="pre">Home</span></code> - Move selected objects to Top (with Manual object
drawing order)</li>
<li><code class="docutils literal notranslate"><span class="pre">End</span></code> - Move selected objects to Bottom (with Manual object
drawing order)</li>
</ul>
</li>
<li><code class="docutils literal notranslate"><span class="pre">O</span></code> - Activate <a class="reference internal" href="index.html#edit-polygons-tool"><span class="std std-ref">Edit Polygons</span></a></li>
<li><code class="docutils literal notranslate"><span class="pre">R</span></code> - Activate <a class="reference internal" href="index.html#insert-rectangle-tool"><span class="std std-ref">Insert Rectangle</span></a></li>
<li><code class="docutils literal notranslate"><span class="pre">I</span></code> - Activate <a class="reference internal" href="index.html#insert-point-tool"><span class="std std-ref">Insert Point</span></a></li>
<li><code class="docutils literal notranslate"><span class="pre">C</span></code> - Activate <a class="reference internal" href="index.html#insert-ellipse-tool"><span class="std std-ref">Insert Ellipse</span></a></li>
<li><code class="docutils literal notranslate"><span class="pre">P</span></code> - Activate <a class="reference internal" href="index.html#insert-polygon-tool"><span class="std std-ref">Insert Polygon</span></a><ul>
<li><code class="docutils literal notranslate"><span class="pre">Enter</span></code> - Finish creating object</li>
<li><code class="docutils literal notranslate"><span class="pre">Escape</span></code> - Cancel creating object</li>
</ul>
</li>
<li><code class="docutils literal notranslate"><span class="pre">T</span></code> - Activate <a class="reference internal" href="index.html#insert-tile-tool"><span class="std std-ref">Insert Tile</span></a></li>
<li><code class="docutils literal notranslate"><span class="pre">V</span></code> - Activate <a class="reference internal" href="index.html#insert-template-tool"><span class="std std-ref">Insert Template</span></a> (since Tiled 1.1)</li>
<li><code class="docutils literal notranslate"><span class="pre">E</span></code> - Activate <a class="reference internal" href="index.html#insert-text-tool"><span class="std std-ref">Insert Text</span></a></li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">A</span></code> - Select all objects in the current object layer</li>
<li><code class="docutils literal notranslate"><span class="pre">Ctrl</span> <span class="pre">+</span> <span class="pre">Shift</span> <span class="pre">+</span> <span class="pre">A</span></code> - Clear object selection</li>
</ul>
</div>
<div class="section" id="in-the-properties-dialog">
<h3>In the Properties dialog<a class="headerlink" href="#in-the-properties-dialog" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">Del</span></code> or <code class="docutils literal notranslate"><span class="pre">Backspace</span></code> - Deletes a property</li>
</ul>
</div>
</div>
<span id="document-manual/preferences"></span><div class="section" id="user-preferences">
<h2>User Preferences<a class="headerlink" href="#user-preferences" title="Permalink to this headline">¶</a></h2>
<p>There are only a few options located in the Preferences, accessible
though the menu via <em>Edit &gt; Preferences</em>. Most other options, like
whether to draw the grid, what kind snapping to do or the last used
settings when creating a new map are simply remembered persistently.</p>
<p>The preferences are stored in a system-dependent format and location:</p>
<table border="1" class="docutils">
<colgroup>
<col width="17%" />
<col width="83%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>Windows</strong></td>
<td>Registry key <code class="docutils literal notranslate"><span class="pre">HKEY_CURRENT_USER\SOFTWARE\mapeditor.org\Tiled</span></code></td>
</tr>
<tr class="row-even"><td><strong>macOS</strong></td>
<td><code class="file docutils literal notranslate"><span class="pre">~/Library/Preferences/org.mapeditor.Tiled.plist</span></code></td>
</tr>
<tr class="row-odd"><td><strong>Linux</strong></td>
<td><code class="file docutils literal notranslate"><span class="pre">~/.config/mapeditor.org/tiled.conf</span></code></td>
</tr>
</tbody>
</table>
<div class="section" id="general">
<h3>General<a class="headerlink" href="#general" title="Permalink to this headline">¶</a></h3>
<div class="figure align-right">
<a class="reference internal image-reference" href="_images/preferences-general.png"><img alt="General Preferences" src="_images/preferences-general.png" style="width: 347.0px; height: 337.0px;" /></a>
</div>
<div class="section" id="saving-and-loading">
<h4>Saving and Loading<a class="headerlink" href="#saving-and-loading" title="Permalink to this headline">¶</a></h4>
<dl class="docutils">
<dt>Include DTD reference in saved maps</dt>
<dd>This option is not enabled by default, since it is of very little
use whereas it can in some environments cause problems. Feel free to
enable it if it helps with validation for example, but note that the
referenced DTD is likely out of date (there is a somewhat more up-to-date
XSD file available in the repository).</dd>
<dt>Reload tileset images when they change</dt>
<dd>This is very useful while working on the tiles or when the tiles
might change as a result of a source control system.</dd>
<dt>Open last files on startup</dt>
<dd>Generally a useful thing to keep enabled.</dd>
<dt>Use safe writing of files</dt>
<dd>This setting causes files to be written to a temporary file, and
when all went well, to be swapped with the target file. This avoids
data getting lost due to errors while saving or due to insufficient
disk space. Unfortunately, it is known to cause issues when saving
files to a Dropbox folder or a network drive, in which case it helps
to disable this feature.</dd>
</dl>
<div class="new new-prev">Since Tiled 1.2</div></div>
<div class="section" id="export-options">
<span id="id1"></span><h4>Export Options<a class="headerlink" href="#export-options" title="Permalink to this headline">¶</a></h4>
<p>The following export options are applied each time a map or tileset gets
exported, without affecting the map or tileset itself.</p>
<dl class="docutils">
<dt>Embed tilesets</dt>
<dd>All tilesets are embedded in the exported map. Useful for example
when you are exporting to JSON and loading an external tileset is
not desired.</dd>
<dt>Detach templates</dt>
<dd>All template instances are detached. Useful when you want to use the
templates feature but can’t or don’t want to load the external
template object files.</dd>
<dt>Resolve object types and properties</dt>
<dd>Stores effective object type and properties with each object.
Object properties are inherited from a tile (in case of a tile
object) and from the default properties of their type.</dd>
<dt>Minimize output</dt>
<dd>Omits unnecessary whitespace in the output file. This option is supported
for XML (TMX and TSX), JSON and Lua formats.</dd>
</dl>
<p>These options are also available as options when exporting using the
command-line.</p>
</div>
</div>
<div class="section" id="interface">
<h3>Interface<a class="headerlink" href="#interface" title="Permalink to this headline">¶</a></h3>
<div class="section" id="id2">
<h4>Interface<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h4>
<dl class="docutils">
<dt>Language</dt>
<dd>By default the language tries to match that of the system, but if it
picks the wrong one you can change it here.</dd>
<dt>Grid colour</dt>
<dd>Because black is not always the best color for the grid.</dd>
<dt>Fine grid divisions</dt>
<dd>The tile grid can be divided further using this setting, which
affects the “Snap to Fine Grid” setting in the <em>View &gt; Snapping</em>
menu.</dd>
<dt>Object line width</dt>
<dd>Shapes are by default rendered with a 2 pixel wide line, but some
people like it thinner or even thicker. On some systems the DPI-based
scaling will affect this setting as well.</dd>
<dt>Hardware accelerated drawing (OpenGL)</dt>
<dd>This enables a rather unoptimized way of rendering the map using
OpenGL. It’s usually not an improvement and may lead to crashes, but
in some scenarios it can make editing more responsive.</dd>
</dl>
<div class="new new-prev">Since Tiled 1.1</div><dl class="docutils">
<dt>Mouse wheel zooms by default</dt>
<dd>This option causes the mouse wheel to zoom without the need to hold
Control (or Command on macOS). It can be a convenient way to
navigate the map, but it can also interfere with panning on a
touchpad.</dd>
</dl>
<div class="new new-prev">Since Tiled 1.3</div></div>
<div class="section" id="updates">
<h4>Updates<a class="headerlink" href="#updates" title="Permalink to this headline">¶</a></h4>
<p>By default, Tiled checks for news and new versions and highlights any updates
in the status bar. Here you can disable this functionality. It is recommended
to keep at least one of these enabled.</p>
<p>If you disable displaying of new versions, you can still manually check
whether a new version is available by opening the <em>About Tiled</em> dialog.</p>
<div class="new new-prev">Since Tiled 1.3</div></div>
</div>
<div class="section" id="keyboard">
<span id="keyboard-options"></span><h3>Keyboard<a class="headerlink" href="#keyboard" title="Permalink to this headline">¶</a></h3>
<p>Here you can add, remove or change the keyboard shortcuts of most available
actions.</p>
<p>Conflicting keybindings are highlighted in red. They will not work until you
resolve the conflict.</p>
<p>If you customize multiple shortcuts, it is recommended to use the export
functionality to save the keybindings somewhere, so that you can easily
recover that setup or copy it to other Tiled installations.</p>
</div>
<div class="section" id="theme">
<h3>Theme<a class="headerlink" href="#theme" title="Permalink to this headline">¶</a></h3>
<p>On Windows and Linux, the default style used by Tiled is “Tiled Fusion”.
This is a customized version of the “Fusion” style that ships with Qt.
On macOS, this style can also be used, but because it looks so out of
place the default is “Native” there.</p>
<p>The “Tiled Fusion” style allows customizing the base color. When
choosing a dark base color, the text automatically switches to white and
some other adjustments are made to keep things readable. You can also
choose a custom selection color.</p>
<p>The “Native” style tries to fit in with the operating system, and is
available since it is in some cases preferable to the custom style. The
base color and selection color can’t be changed when using this style,
as they depend on the system.</p>
</div>
<div class="section" id="plugins">
<h3>Plugins<a class="headerlink" href="#plugins" title="Permalink to this headline">¶</a></h3>
<p>Here you can choose which plugins are enabled, as well as opening the
<a class="reference internal" href="index.html#document-reference/scripting"><span class="doc">scripted extensions</span></a> folder.</p>
<p>Plugins add support for map and/or tileset file formats. Some generic plugins
are enabled by default, while more specific ones need to be manually enabled.</p>
<p>There is no need to restart Tiled when enabling or disabling plugins.
When a plugin fails to load, try hovering its icon to see if the tool
tip displays a useful error message.</p>
<p>See <a class="reference internal" href="index.html#document-manual/export"><span class="doc">Export Formats</span></a> for more information about supported file formats.</p>
</div>
</div>
<span id="document-manual/python"></span><div class="section" id="python-scripts">
<h2>Python Scripts<a class="headerlink" href="#python-scripts" title="Permalink to this headline">¶</a></h2>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Since Tiled 1.3, Tiled can be <a class="reference internal" href="index.html#document-reference/scripting"><span class="doc">extended using JavaScript</span></a>. The JavaScript API provides a lot more
opportunity for extending Tiled’s functionality than just adding custom
map formats. It is fully documented and works out of the box on all
platforms. It should be preferred over the Python plugin when possible.</p>
</div>
<p>Tiled ships with a plugin that enables you to use Python 3 to add
support for custom map formats. This is nice especially since you don’t
need to compile Tiled yourself and the scripts are easy to deploy to any
platform.</p>
<p>For the scripts to get loaded, they should be placed in <code class="docutils literal notranslate"><span class="pre">~/.tiled</span></code>.
Tiled watches this directory for changes, so there is no need to restart
Tiled after adding or changing scripts (though the directory needs to
exist when you start Tiled).</p>
<p>There are several <a class="reference external" href="https://github.com/bjorn/tiled/tree/master/src/plugins/python/scripts">example scripts</a> available in the repository.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>To create the <code class="docutils literal notranslate"><span class="pre">~/.tiled</span></code> folder on Windows, open command prompt
(<code class="docutils literal notranslate"><span class="pre">cmd.exe</span></code>), which should  start in your home folder by default, then
type <code class="docutils literal notranslate"><span class="pre">mkdir</span> <span class="pre">.tiled</span></code> to create the folder.</p>
<p class="last">On Linux, folders starting with a dot are hidden by default. In most file
managers you can toggle showing of hidden files using <code class="docutils literal notranslate"><span class="pre">Ctrl+H</span></code>.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Since Tiled 1.2.4, the Python plugin is disabled by default, because
depending on which Python version is installed on the system the loading of
this plugin may cause a crash (<a class="reference external" href="https://github.com/bjorn/tiled/issues/2091">#2091</a>). To use the Python plugin, first
enable it in the Preferences.</p>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p>On Windows, Python is not installed by default. For the Tiled Python
plugin to work, you’ll need to install Python 3.7 (get it from
<a class="reference external" href="https://www.python.org/">https://www.python.org/</a>). You will also need to check the box “Add Python
3.7 to PATH” in the installer:</p>
<div class="figure">
<img alt="_images/python-windows.png" src="_images/python-windows.png" />
</div>
<p>On Linux you will also need to install the appropriate package.
However, currently Linux builds are done on Ubuntu 16.04 against
Python 3.5, and you’d need to install the same version somehow.</p>
<p class="last">The Python plugin is currently not enabled for macOS releases. We’ll
need to find out how to build it against Python 3, while macOS only
ships with Python 2.7 by default. If you rely on this plugin on
macOS you’ll need to use Tiled 1.1 for now.</p>
</div>
<div class="section" id="example-export-plugin">
<h3>Example Export Plugin<a class="headerlink" href="#example-export-plugin" title="Permalink to this headline">¶</a></h3>
<p>Suppose you’d like to have a map exported in the following format:</p>
<div class="code highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">32</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="mi">34</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span>
<span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">32</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="mi">34</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span>
<span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">32</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="mi">34</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span>
<span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">32</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="mi">34</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span>
<span class="mi">25</span><span class="p">,</span><span class="mi">25</span><span class="p">,</span><span class="mi">25</span><span class="p">,</span><span class="mi">25</span><span class="p">,</span><span class="mi">25</span><span class="p">,</span><span class="mi">25</span><span class="p">,</span><span class="mi">44</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="mi">34</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span>
<span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="mi">34</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span>
<span class="mi">41</span><span class="p">,</span><span class="mi">41</span><span class="p">,</span><span class="mi">41</span><span class="p">,</span><span class="mi">41</span><span class="p">,</span><span class="mi">41</span><span class="p">,</span><span class="mi">41</span><span class="p">,</span><span class="mi">41</span><span class="p">,</span><span class="mi">41</span><span class="p">,</span><span class="mi">42</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">24</span><span class="p">,</span><span class="mi">25</span><span class="p">,</span><span class="mi">25</span><span class="p">,</span><span class="mi">25</span><span class="p">,</span>
<span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">32</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span>
<span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">39</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">32</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="mi">35</span><span class="p">,</span><span class="mi">41</span><span class="p">,</span>
<span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">32</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="mi">34</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span>
<span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">37</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">29</span><span class="p">,</span><span class="mi">32</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="mi">34</span><span class="p">,</span><span class="mi">29</span><span class="p">;</span>
</pre></div>
</div>
<p>You can achieve this by saving the following <code class="docutils literal notranslate"><span class="pre">example.py</span></code> script in
the scripts directory:</p>
<div class="code python highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">tiled</span> <span class="k">import</span> <span class="o">*</span>

<span class="k">class</span> <span class="nc">Example</span><span class="p">(</span><span class="n">Plugin</span><span class="p">):</span>
    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">nameFilter</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span>
        <span class="k">return</span> <span class="s2">&quot;Example files (*.example)&quot;</span>

    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">shortName</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span>
        <span class="k">return</span> <span class="s2">&quot;example&quot;</span>

    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">tileMap</span><span class="p">,</span> <span class="n">fileName</span><span class="p">):</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">fileName</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fileHandle</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">tileMap</span><span class="o">.</span><span class="n">layerCount</span><span class="p">()):</span>
                <span class="k">if</span> <span class="n">isTileLayerAt</span><span class="p">(</span><span class="n">tileMap</span><span class="p">,</span> <span class="n">i</span><span class="p">):</span>
                    <span class="n">tileLayer</span> <span class="o">=</span> <span class="n">tileLayerAt</span><span class="p">(</span><span class="n">tileMap</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
                    <span class="k">for</span> <span class="n">y</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">tileLayer</span><span class="o">.</span><span class="n">height</span><span class="p">()):</span>
                        <span class="n">tiles</span> <span class="o">=</span> <span class="p">[]</span>
                        <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">tileLayer</span><span class="o">.</span><span class="n">width</span><span class="p">()):</span>
                            <span class="k">if</span> <span class="n">tileLayer</span><span class="o">.</span><span class="n">cellAt</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">tile</span><span class="p">()</span> <span class="o">!=</span> <span class="kc">None</span><span class="p">:</span>
                                <span class="n">tiles</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">tileLayer</span><span class="o">.</span><span class="n">cellAt</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">tile</span><span class="p">()</span><span class="o">.</span><span class="n">id</span><span class="p">()))</span>
                            <span class="k">else</span><span class="p">:</span>
                                <span class="n">tiles</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">))</span>
                        <span class="n">line</span> <span class="o">=</span> <span class="s1">&#39;,&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">tiles</span><span class="p">)</span>
                        <span class="k">if</span> <span class="n">y</span> <span class="o">==</span> <span class="n">tileLayer</span><span class="o">.</span><span class="n">height</span><span class="p">()</span> <span class="o">-</span> <span class="mi">1</span><span class="p">:</span>
                            <span class="n">line</span> <span class="o">+=</span> <span class="s1">&#39;;&#39;</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">line</span> <span class="o">+=</span> <span class="s1">&#39;,&#39;</span>
                        <span class="nb">print</span><span class="p">(</span><span class="n">line</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">fileHandle</span><span class="p">)</span>


        <span class="k">return</span> <span class="kc">True</span>
</pre></div>
</div>
<p>Then you should see an “Example files” entry in the type dropdown when
going to <em>File &gt; Export</em>, which allows you to export the map using the
above script.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This example does not support the use of group layers, and in fact
the script API doesn’t support this yet either. Any help with
maintaining the Python plugin would be very appreciated. See
<a class="reference external" href="https://github.com/bjorn/tiled/issues?utf8=%E2%9C%93&amp;q=is%3Aissue+is%3Aopen+python+in%3Atitle">open issues related to Python support</a>.</p>
</div>
</div>
<div class="section" id="debugging-your-script">
<h3>Debugging Your Script<a class="headerlink" href="#debugging-your-script" title="Permalink to this headline">¶</a></h3>
<p>Any errors that happen while parsing or running the script are printed
to the Console, which can be enabled in <em>View &gt; Views and Toolbars
&gt; Console</em>.</p>
</div>
<div class="section" id="api-reference">
<h3>API Reference<a class="headerlink" href="#api-reference" title="Permalink to this headline">¶</a></h3>
<p>It would be nice to have the full API reference documented here, but for
now please check out the <a class="reference external" href="https://github.com/bjorn/tiled/blob/master/src/plugins/python/tiledbinding.py">source file</a> for available classes and
methods.</p>
</div>
</div>
</div>
<div class="toctree-wrapper compound">
<span id="document-reference/support-for-tmx-maps"></span><div class="section" id="libraries-and-frameworks">
<h2>Libraries and Frameworks<a class="headerlink" href="#libraries-and-frameworks" title="Permalink to this headline">¶</a></h2>
<p>There are many libraries available for reading and/or writing Tiled maps (either stored in the
<a class="reference internal" href="index.html#document-reference/tmx-map-format"><span class="doc">TMX Map Format</span></a> or the <a class="reference internal" href="index.html#document-reference/json-map-format"><span class="doc">JSON Map Format</span></a>) as well as many
development frameworks that include support for Tiled maps. This list is
divided into two sections:</p>
<ul class="simple">
<li><a class="reference external" href="#support-by-language">Support by Language</a></li>
<li><a class="reference external" href="#support-by-framework">Support by Framework</a></li>
</ul>
<p>The first list is for developers who plan on implementing their own
renderer. The second list is for developers already using (or
considering) a particular game engine / graphics library who would
rather pass on having to write their own tile map renderer.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">For updates to this page please open a pull request or issue
<a class="reference external" href="https://github.com/bjorn/tiled/issues">on GitHub</a>, thanks!</p>
</div>
<div class="section" id="support-by-language">
<h3>Support by Language<a class="headerlink" href="#support-by-language" title="Permalink to this headline">¶</a></h3>
<p>These libraries typically include only a TMX parser, but no rendering
support. They can be used universally and should not require a specific
game engine or graphics library.</p>
<div class="section" id="c">
<h4>C<a class="headerlink" href="#c" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/RandyGaul/cute_headers">cute tiled</a> - JSON map loader with examples (zlib/Public Domain).</li>
<li><a class="reference external" href="https://github.com/baylej/tmx/">TMX</a> - TMX map loader
with Allegro5 and SDL2 examples (BSD).</li>
</ul>
</div>
<div class="section" id="id1">
<h4>C++<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/sainteos/tmxparser">C++/TinyXML based tmxparser</a> (BSD)</li>
<li>C++/Qt based libtiled, used by Tiled itself and included at
<a class="reference external" href="https://github.com/bjorn/tiled/tree/master/src/libtiled">src/libtiled</a>
(BSD)</li>
<li><a class="reference external" href="https://github.com/halsafar/libtmx-parser">C++11x/TinyXml2
libtmx-parser</a> by
halsafar. (zlib/tinyxml2)</li>
<li><a class="reference external" href="https://github.com/jube/libtmx">C++11/TinyXml2 libtmx</a> by jube,
for reading only (ISC licence). See
<a class="reference external" href="http://jube.github.io/libtmx/index.html">documentation</a>.</li>
<li><a class="reference external" href="https://github.com/solar-storm-studios/TMXParser">TMXParser</a>
General *.tmx tileset data loader. Intended to be used with
TSXParser for external tileset loading. (No internal tileset support)</li>
<li><a class="reference external" href="https://github.com/solar-storm-studios/TSXParser">TSXParser</a>
General *.tsx tileset data loader. Intended to be used with
TMXParser.</li>
<li><a class="reference external" href="https://bitbucket.org/martingrant/tmxloader">TMXLoader</a> based on
<a class="reference external" href="http://rapidxml.sourceforge.net/">RapidXml</a>. Limited
functionality (check the
<a class="reference external" href="http://www.midnightpacific.com/portfolio/tmxloader-for-tiled-map-editor/">website</a>
for details).</li>
<li><a class="reference external" href="https://github.com/fallahn/tmxlite">tmxlite</a> C++14 map parser
with compressed map support but no external linking required.
Includes examples for SFML and SDL2 rendering. Currently has full tmx
support up to 0.16. (Zlib/libpng)</li>
<li><a class="reference external" href="https://github.com/SSBMTonberry/tileson">Tileson</a> - A Tiled JSON parser for modern C++ (C++17) by Robin Berg Pettersen (BSD)</li>
</ul>
</div>
<div class="section" id="c-net">
<h4>C#/.NET<a class="headerlink" href="#c-net" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/craftworkgames/MonoGame.Extended">MonoGame.Extended</a>
has a Tiled map loader and renderer that works with MonoGame on all
platforms that support portable class libraries.</li>
<li><a class="reference external" href="https://github.com/zachmu/tiled-xna">XNA map loader</a> by Kevin
Gadd, extended by Stephen Belanger and Zach Musgrave (has dependency
on XNA but supposedly can be turned into a standalone parser easily)</li>
<li><a class="reference external" href="https://github.com/marshallward/TiledSharp">TiledSharp</a>: Yet
another C# TMX importer library, with Tiled 0.11 support. TiledSharp
is a generic parser which can be used in any framework, but it cannot
be used to render the maps. Available via NuGet.</li>
<li><a class="reference external" href="https://github.com/patriksvensson/ntiled">NTiled</a>: Generic parser
for 0.9.1 tiled maps. Available via NuGet.</li>
<li><a class="reference external" href="https://github.com/gwicksted/TmxCSharp">TmxCSharp</a>: Useful for
multi-layer orthographic tile engines. No framework dependencies,
used with a custom OpenTK tile engine soon to be open source, tested
with Tiled 0.8.1 (multiple output formats). MIT license.</li>
<li><a class="reference external" href="https://github.com/aalmik/tmx-mapper-pcl">tmx-mapper-pcl</a>: PCL
library for parsing Tiled map TMX files. This library could be used
with MonoGame and Windows Runtime Universal apps.</li>
</ul>
</div>
<div class="section" id="clojure">
<h4>Clojure<a class="headerlink" href="#clojure" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/oakes/tile-soup">tile-soup</a>: Parses and validates a TMX file into a map. Automatically decodes Base64 and CSV formatted data and coerces numbers when necessary. Works on both the JVM and in browsers via ClojureScript.</li>
</ul>
</div>
<div class="section" id="d">
<h4>D<a class="headerlink" href="#d" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://gist.github.com/gdm85/9896961">tiledMap.d</a> simple
single-layer and single-tileset example to load a map and its tileset
in <a class="reference external" href="http://dlang.org/">D language</a>. It also contains basic
rendering logic using <a class="reference external" href="https://github.com/Jebbs/DSFML/">DSFML</a></li>
<li><a class="reference external" href="https://github.com/rcorre/dtiled">dtiled</a> can load JSON-formatted Tiled
maps. It also provides general tilemap-related functions and algorithms.</li>
</ul>
</div>
<div class="section" id="go">
<h4>Go<a class="headerlink" href="#go" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/lafriks/go-tiled">github.com/lafriks/go-tiled</a></li>
<li><a class="reference external" href="https://github.com/salviati/go-tmx">github.com/salviati/go-tmx/tmx</a></li>
</ul>
</div>
<div class="section" id="haskell">
<h4>Haskell<a class="headerlink" href="#haskell" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://hackage.haskell.org/package/htiled">htiled</a> (TMX) by <a class="reference external" href="https://github.com/chrra">Christian
Rødli Amble</a>.</li>
<li><a class="reference external" href="https://hackage.haskell.org/package/aeson-tiled">aeson-tiled</a> (JSON) by <a class="reference external" href="https://github.com/schell">Schell Scivally</a>.</li>
</ul>
</div>
<div class="section" id="java">
<h4>Java<a class="headerlink" href="#java" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>A library for loading TMX files is included with Tiled at
<a class="reference external" href="https://github.com/bjorn/tiled/tree/master/util/java/libtiled-java">util/java/libtiled-java</a>.</li>
<li><a class="reference external" href="http://www.alexheyman.org/tiledreader/">TiledReader</a> is a simple TMX reader that conveys the information in Tiled files via a hand-crafted class structure, but does not load image data.</li>
<li>Android-Specific:<ul>
<li><a class="reference external" href="https://github.com/davidmi/Android-TMX-Loader">AndroidTMXLoader</a>
loads TMX data into an object and renders to an Android Bitmap
(limited functionality)</li>
<li><a class="reference external" href="http://chiselapp.com/user/devnewton/repository/libtiled-android/index">libtiled-java
port</a>
is a port of the libtiled-java to be used on Android phones.</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="php">
<h4>PHP<a class="headerlink" href="#php" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/sebbu2/php-tmx-viewer">PHP TMX Viewer</a> by
sebbu : render the map as an image (allow some modifications as well)</li>
</ul>
</div>
<div class="section" id="pike">
<h4>Pike<a class="headerlink" href="#pike" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://gitlab.com/tmx-parser/tmx-parser">TMX parser</a>: a simple
loader for TMX maps (CSV format only).</li>
</ul>
</div>
<div class="section" id="processing">
<h4>Processing<a class="headerlink" href="#processing" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/linux-man/ptmx">linux-man/ptmx</a>: Add Tiled
maps to your Processing sketch.</li>
</ul>
</div>
<div class="section" id="python">
<h4>Python<a class="headerlink" href="#python" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/Beefy-Swain/pytiled_parser">pytiled-parser</a>: Python parser
for TMX maps</li>
<li><a class="reference external" href="http://arcade.academy">Arcade</a>: 2D game library that uses pytiled-parser for
easy loading of TMX maps into a game. <a class="reference external" href="http://arcade.academy/examples/index.html#tmx-files-tiled-map-editor">Arcade TMX Examples</a></li>
<li><a class="reference external" href="http://pytmxlib.readthedocs.org/en/latest/">pytmxlib</a>: library
for programmatic manipulation of TMX maps</li>
<li><a class="reference external" href="http://python-tmx.nongnu.org">python-tmx</a>: a simple library for
reading and writing TMX files.</li>
</ul>
</div>
<div class="section" id="ruby">
<h4>Ruby<a class="headerlink" href="#ruby" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/shawn42/tmx">tmx gem</a> by erisdiscord</li>
</ul>
</div>
<div class="section" id="vala">
<h4>Vala<a class="headerlink" href="#vala" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/JumpLink/librpg">librpg</a> A library to load and
handle spritesets (own format) and orthogonal TMX maps.</li>
</ul>
</div>
</div>
<div class="section" id="support-by-framework">
<h3>Support by Framework<a class="headerlink" href="#support-by-framework" title="Permalink to this headline">¶</a></h3>
<p>Following entries are integrated solutions for specific game engines.
They are typically of little to no use if you’re not using said game
engine.</p>
<div class="section" id="andengine">
<h4>AndEngine<a class="headerlink" href="#andengine" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://www.andengine.org/">AndEngine</a> by Nicolas Gramlich
supports <a class="reference external" href="http://www.andengine.org/blog/2010/07/andengine-tiledmaps-in-the-tmx-format/">rendering TMX
maps</a></li>
</ul>
</div>
<div class="section" id="allegro">
<h4>Allegro<a class="headerlink" href="#allegro" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/dradtke/allegro_tiled">allegro_tiled</a>
integrates Tiled support with <a class="reference external" href="http://alleg.sourceforge.net/">Allegro
5</a>.</li>
</ul>
</div>
<div class="section" id="castle-game-engine-object-pascal">
<h4>Castle Game Engine (Object Pascal)<a class="headerlink" href="#castle-game-engine-object-pascal" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://castle-engine.io/">Castle Game Engine</a> has native support for Tiled maps (see the <a class="reference external" href="https://castle-engine.io/apidoc-unstable/html/CastleTiledMap.html">CastleTiledMap unit</a>)</li>
</ul>
</div>
<div class="section" id="cell2d">
<h4>Cell2D<a class="headerlink" href="#cell2d" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The Java library <a class="reference external" href="https://www.cell2d.org/">Cell2D</a> supports Tiled maps via a pipeline that starts with <a class="reference external" href="http://www.alexheyman.org/tiledreader/">TiledReader</a>, but currently has more built-in support for orthogonal maps than for other orientations.</li>
</ul>
</div>
<div class="section" id="cocos2d">
<h4>cocos2d<a class="headerlink" href="#cocos2d" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://python.cocos2d.org/">cocos2d (Python)</a> supports loading
<a class="reference external" href="http://python.cocos2d.org/doc/programming_guide/tiled_map.html">Tiled
maps</a>
through its <code class="docutils literal notranslate"><span class="pre">cocos.tiles</span></code> module.</li>
<li><a class="reference external" href="http://www.cocos2d-x.org/">cocos2d-x (C++)</a> supports loading TMX
maps through the
<a class="reference external" href="http://www.cocos2d-x.org/reference/native-cpp/V2.1.4/da/d68/classcocos2d_1_1_c_c_t_m_x_tiled_map.html">CCTMXTiledMap</a>
class.</li>
<li><a class="reference external" href="http://www.cocos2d-objc.org/">cocos2d-objc (Objective-C, Swift)</a>
(previously known as: cocos2d-iphone, cocos2d-swift,
cocos2d-spritebuilder) supports loading TMX maps through
<a class="reference external" href="http://cocos2d.spritebuilder.com/docs/api/Classes/CCTiledMap.html">CCTiledMap</a></li>
<li><a class="reference external" href="http://tilemapkit.com">TilemapKit</a> is a tilemapping framework for
Cocos2D. It supports all TMX tilemap types, including staggered iso
and all hex variations. No longer in development.</li>
</ul>
</div>
<div class="section" id="construct-2-scirra">
<h4>Construct 2 - Scirra<a class="headerlink" href="#construct-2-scirra" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://www.scirra.com">Construct 2</a>, since the Beta Release 149,
officially supports TMX maps, and importing it by simple dragging the
file inside the editor. <a class="reference external" href="https://www.scirra.com/construct2/releases/r149">Official
Note</a></li>
</ul>
</div>
<div class="section" id="flixel">
<h4>Flixel<a class="headerlink" href="#flixel" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Lithander demonstrated his <a class="reference external" href="http://blog.pixelpracht.net/?p=59">Flash TMX parser combined with Flixel
rendering</a></li>
</ul>
</div>
<div class="section" id="game-maker">
<h4>Game Maker<a class="headerlink" href="#game-maker" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Tiled ships with a plug-in that can <a class="reference internal" href="index.html#gamemaker-export"><span class="std std-ref">export a map to a GameMaker: Studio 1.4 room file</span></a></li>
<li><a class="reference external" href="http://gmc.yoyogames.com/index.php?showtopic=539494">Tiled2GM Converter</a> by Dmi7ry</li>
</ul>
</div>
<div class="section" id="godot">
<h4>Godot<a class="headerlink" href="#godot" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://godotengine.org/asset-library/asset/25">Tiled Map Importer</a> imports each map as Godot scene which can be instanced or inherited (<a class="reference external" href="http://discourse.mapeditor.org/t/importer-plugin-for-godot-engine/1833/1">forum announcement</a>).</li>
<li><a class="reference external" href="https://github.com/MikeMnD/tiled-to-godot-export">Tiled To Godot Export</a> is a Tiled <a class="reference internal" href="index.html#document-reference/scripting"><span class="doc">JavaScript extension</span></a> for exporting Tilemaps and Tilesets in Godot 3.2 format (<a class="reference external" href="https://discourse.mapeditor.org/t/tiled-editor-map-and-tileset-integration-with-godot-3-2/4347">forum announcement</a>).</li>
</ul>
</div>
<div class="section" id="grid-engine">
<h4>Grid Engine<a class="headerlink" href="#grid-engine" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Planimeter’s <a class="reference external" href="https://www.planimeter.org/grid-sdk/">Grid Engine</a> supports Tiled Lua-exported maps.</li>
</ul>
</div>
<div class="section" id="haxe">
<h4>Haxe<a class="headerlink" href="#haxe" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/HaxePunk/tiled">HaxePunk</a> Tiled Loader for
HaxePunk</li>
<li><a class="reference external" href="https://github.com/HaxeFlixel/flixel-addons/tree/dev/flixel/addons/editors/tiled">HaxeFlixel</a></li>
<li><a class="reference external" href="https://github.com/Kasoki/openfl-tiled">OpenFL</a> “openfl-tiled” is
a library, which gives OpenFL developers the ability to use the Tiled
Map Editor.</li>
<li><a class="reference external" href="https://github.com/kasoki/openfl-tiled-flixel">OpenFL + Tiled +
Flixel</a>
Experimental glue to use “openfl-tiled” with HaxeFlixel</li>
</ul>
</div>
<div class="section" id="html5-multiple-engines">
<h4>HTML5 (multiple engines)<a class="headerlink" href="#html5-multiple-engines" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/RSamaium/CanvasEngine">Canvas Engine</a> A framework to create
video games in HTML5 Canvas</li>
<li><a class="reference external" href="https://github.com/andrewrk/chem-tmx">chem-tmx</a> Plugin for
<a class="reference external" href="https://github.com/andrewrk/chem/">chem</a> game engine.</li>
<li><a class="reference external" href="https://github.com/funkaster/ChesterGL">chesterGL</a> A simple
WebGL/canvas game library</li>
<li><a class="reference external" href="http://craftyjs.com">Crafty</a> JavaScript HTML5 Game Engine;
supports loading Tiled maps through an external component
<a class="reference external" href="https://github.com/Kibo/TiledMapBuilder">TiledMapBuilder</a>.</li>
<li><a class="reference external" href="http://gamejs.org">GameJs</a> JavaScript library for game
programming; a thin wrapper to draw on HTML5 canvas and other useful
modules for game development</li>
<li><a class="reference external" href="https://github.com/Wappworks/kineticjs-ext">KineticJs-Ext</a> A
multi-canvas based game rendering library</li>
<li><a class="reference external" href="http://www.melonjs.org">melonJS</a> A lightweight HTML5 game engine</li>
<li><a class="reference external" href="https://www.panda2.io/">Panda 2</a>, a HTML5 Game Development Platform for Mac, Windows and Linux. Has <a class="reference external" href="https://www.panda2.io/plugins">a plugin for rendering Tiled</a> maps, both orthogonal and isometric.</li>
<li><a class="reference external" href="http://www.phaser.io">Phaser</a> A fast, free and fun open source
framework supporting both JavaScript and TypeScript (<a class="reference external" href="http://www.gamedevacademy.org/html5-phaser-tutorial-top-down-games-with-tiled/">Tiled
tutorial</a>)</li>
<li><a class="reference external" href="https://github.com/linux-man/p5.tiledmap">linux-man/p5.tiledmap</a>
adds Tiled maps to <a class="reference external" href="http://p5js.org/">p5.js</a>.</li>
<li><a class="reference external" href="https://github.com/PBS-KIDS/Platypus/">Platypus Engine</a> A robust
orthogonal tile game engine with game entity library.</li>
<li><a class="reference external" href="https://github.com/batiste/sprite.js">sprite.js</a> A game framework
for image sprites.</li>
<li><a class="reference external" href="https://github.com/cdmckay/tmxjs">TMXjs</a> A JavaScript, jQuery and
RequireJS-based TMX (Tile Map XML) parser and renderer.</li>
</ul>
</div>
<div class="section" id="indielib-crossplatform">
<h4>indielib-crossplatform<a class="headerlink" href="#indielib-crossplatform" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://www.indielib.com">indielib cross-platform</a> supports
loading TMX maps through the <a class="reference external" href="http://code.google.com/p/tmx-parser/">C++/TinyXML based
tmx-parser</a> by KonoM (BSD)</li>
</ul>
</div>
<div class="section" id="libgdx">
<h4>LibGDX<a class="headerlink" href="#libgdx" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://libgdx.badlogicgames.com/">libgdx</a>, a Java-based
Android/desktop/HTML5 game library,
<a class="reference external" href="https://github.com/libgdx/libgdx/wiki/Tile-maps">provides</a> a
packer, loader and renderer for TMX maps</li>
</ul>
</div>
<div class="section" id="litiengine">
<h4>LITIengine<a class="headerlink" href="#litiengine" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://litiengine.com">LITIengine</a> is a 2D Java Game Engine that
supports loading, saving and rendering maps in the .tmx format.</li>
</ul>
</div>
<div class="section" id="love">
<h4>LÖVE<a class="headerlink" href="#love" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/Karai17/Simple-Tiled-Implementation">Simple Tiled
Implementation</a>
Lua loader for the LÖVE (Love2d) game framework.</li>
</ul>
</div>
<div class="section" id="moai-sdk">
<h4>MOAI SDK<a class="headerlink" href="#moai-sdk" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/makotok/Hanappe">Hanappe</a> Framework for MOAI
SDK.</li>
<li><a class="reference external" href="https://github.com/ymobe/rapanui">Rapanui</a> Framework for MOAI
SDK.</li>
</ul>
</div>
<div class="section" id="monkey-x">
<h4>Monkey X<a class="headerlink" href="#monkey-x" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/bitJericho/bit.tiled">bit.tiled</a> Loads TMX
file as objects. Aims to be fully compatible with native TMX files.</li>
<li><a class="reference external" href="https://code.google.com/p/diddy/">Diddy</a> is an extensive
framework for Monkey X that contains a module for loading and
rendering TMX files. Supports orthogonal and isometric maps as both
CSV and Base64 (uncompressed).</li>
</ul>
</div>
<div class="section" id="node-js">
<h4>Node.js<a class="headerlink" href="#node-js" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/andrewrk/node-tmx-parser">node-tmx-parser</a> -
loads the TMX file into a JavaScript object</li>
</ul>
</div>
<div class="section" id="oak-nut-engine-onut">
<h4>Oak Nut Engine (onut)<a class="headerlink" href="#oak-nut-engine-onut" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://daivuk.github.io/onut/">Oak Nut Engine</a> supports Tiled maps
through Javascript and C++. (see TiledMap <a class="reference external" href="https://github.com/Daivuk/onut/tree/master/samplesJS/TiledMap">Javascript</a> or <a class="reference external" href="https://github.com/Daivuk/onut/tree/master/samples/TiledMap">C++</a> samples)</li>
</ul>
</div>
<div class="section" id="orx-portable-game-engine">
<h4>Orx Portable Game Engine<a class="headerlink" href="#orx-portable-game-engine" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://orx-project.org/wiki/tutorials/community/sausage/tmx_to_orx">TMX to ORX
Converter</a>
Tutorial and converter download for Orx.</li>
</ul>
</div>
<div class="section" id="pygame">
<h4>Pygame<a class="headerlink" href="#pygame" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://www.pygame.org/project/1158/">Pygame map loader</a> by dr0id</li>
<li><a class="reference external" href="https://github.com/bitcraft/PyTMX">PyTMX</a> by Leif Theden
(bitcraft)</li>
<li><a class="reference external" href="https://bitbucket.org/r1chardj0n3s/pygame-tutorial/src/a383dd24790d/tmx.py">tmx.py</a>
by Richard Jones, from his <a class="reference external" href="http://pyvideo.org/video/615/introduction-to-game-development">2012 PyCon ‘Introduction to Game
Development’
talk</a>.</li>
<li><a class="reference external" href="https://github.com/renfredxh/tmx">TMX</a>, a fork of tmx.py and a
port to Python3. A demo called pylletTown can be found
<a class="reference external" href="https://github.com/renfredxh/pylletTown">here</a>.</li>
</ul>
</div>
<div class="section" id="pyglet">
<h4>Pyglet<a class="headerlink" href="#pyglet" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/reidrac/pyglet-tiled-json-map">JSON map loader/renderer for
pyglet</a> by Juan
J. Martínez (reidrac)</li>
<li><a class="reference external" href="https://github.com/bitcraft/PyTMX">PyTMX</a> by Leif Theden
(bitcraft)</li>
</ul>
</div>
<div class="section" id="pysdl2">
<h4>PySDL2<a class="headerlink" href="#pysdl2" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/bitcraft/PyTMX">PyTMX</a> by Leif Theden
(bitcraft)</li>
</ul>
</div>
<div class="section" id="rpg-maker-mv">
<h4>RPG Maker MV<a class="headerlink" href="#rpg-maker-mv" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://archeia.itch.io/tiled-plugin-for-rpg-maker-mv">Tiled
Plugin for RPG Maker MV</a>
by <a class="reference external" href="http://yami.moe/">Dr.Yami</a> &amp; Archeia, from <a class="reference external" href="https://forums.rpgmakerweb.com">RPG Maker
Web</a></li>
</ul>
</div>
<div class="section" id="sdl">
<h4>SDL<a class="headerlink" href="#sdl" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://usefulgamedev.weebly.com/c-tiled-map-loader.html">C++/TinyXML/SDL based
loader</a>
example by Rohin Knight (limited functionality)</li>
</ul>
</div>
<div class="section" id="sfml">
<h4>SFML<a class="headerlink" href="#sfml" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/edoren/STP">STP</a> (SFML TMX Parser) by edoren</li>
<li><a class="reference external" href="http://trederia.blogspot.co.uk/2013/05/tiled-map-loader-for-sfml.html">C++/SFML Tiled map
loader</a>
by fallahn. (Zlib/libpng)</li>
<li><a class="reference external" href="https://github.com/Tresky/sf_tile_engine">C++/SfTileEngine</a> by
Tresky (currently limited functionality)</li>
</ul>
</div>
<div class="section" id="slick2d">
<h4>Slick2D<a class="headerlink" href="#slick2d" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://slick.ninjacave.com">Slick2D</a> supports loading TMX maps
through
<a class="reference external" href="http://slick.ninjacave.com/javadoc/org/newdawn/slick/tiled/TiledMap.html">TiledMap</a>.</li>
</ul>
</div>
<div class="section" id="solar2d-formerly-corona-sdk">
<h4>Solar2D (formerly Corona SDK)<a class="headerlink" href="#solar2d-formerly-corona-sdk" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/ponywolf/ponytiled">ponytiled</a> is a simple
Tiled Map Loader for Solar2D (<a class="reference external" href="http://discourse.mapeditor.org/t/new-lua-coronasdk-framework-ponytiled/1826">forum
announcement</a>)</li>
<li><a class="reference external" href="https://github.com/GymbylCoding/Dusk-Engine">Dusk Engine</a> is a
fully featured Tiled map game engine for Solar2D (no longer maintained, but may still be useful)</li>
<li><a class="reference external" href="https://github.com/ldurniat/Berry">Berry</a> is a simple Tiled
Map Loader for Solar2D.</li>
<li><a class="reference external" href="https://qiso.qweb.co.uk">Qiso</a> is an isometric engine for Solar2D that supports loading Tiled maps, and also handles things like path-finding for you.</li>
</ul>
</div>
<div class="section" id="sprite-kit-framework">
<h4>Sprite Kit Framework<a class="headerlink" href="#sprite-kit-framework" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://github.com/TomLinthwaite/SKTilemap">SKTilemap</a> is built
from the ground up in Swift. It’s up to date, full of features and
easy to integrate into any Sprite Kit project. Supports iOS and OSX.</li>
<li><a class="reference external" href="https://github.com/mfessenden/SKTiled">SKTiled</a> - A Swift
framework for working with Tiled assets in SpriteKit.</li>
<li><a class="reference external" href="https://github.com/slycrel/JSTileMap">JSTileMap</a> is a lightweight
SpriteKit implementation of the TMX format supporting iOS 7 and OS X
10.9 and above.</li>
</ul>
</div>
<div class="section" id="terra-engine-delphi-pascal">
<h4>TERRA Engine (Delphi/Pascal)<a class="headerlink" href="#terra-engine-delphi-pascal" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://pascalgameengine.com/">TERRA Engine</a> supports loading and
rendering of TMX maps.</li>
</ul>
</div>
<div class="section" id="unity">
<h4>Unity<a class="headerlink" href="#unity" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://seanba.itch.io/supertiled2unity">SuperTiled2Unity</a> is a collection of C# Unity scripts that can automatically import Tiled map editor files directly into your Unity projects.</li>
<li><a class="reference external" href="https://assetstore.unity.com/packages/tools/sprite-management/tiled-tmx-importer-102928">Tiled TMX Importer</a>, imports into Unity 2017.2’s new native Tilemap system.</li>
<li><a class="reference external" href="https://assetstore.unity.com/packages/tools/integration/tiled-to-unity-17260">Tiled to
Unity</a> is a
3D pipeline for Tiled maps. It uses prefabs as tiles, and can place
decorations dynamically on tiles. Supports multiple layers (including
object layers).</li>
<li><a class="reference external" href="https://github.com/ShreveportArcade/Tuesday">Tuesday</a>: A generic
C# serializer and deserializer plus a set of Unity editor
scripts that allow you to drag and drop TMX files into your scene,
make edits, and save back out as TMX files. MIT license.</li>
<li><a class="reference external" href="https://yjaffal.itch.io/unitiled">UniTiled</a>, a native TMX importer for Unity.</li>
<li><a class="reference external" href="https://bitbucket.org/Chaoseiro/x-unitmx">X-UniTMX</a> supports
almost all Tiled 0.11 features. Imports TMX/XML files into Sprite
Objects or Meshes.</li>
<li><a class="reference external" href="http://www.wyrmtale.com/products/unity3d-components/orthello-pro">Orthello
Pro</a>
(2D framework) offers <a class="reference external" href="http://www.wyrmtale.com/orthello-pro/tilemaps">Tiled map
support</a>.</li>
</ul>
</div>
<div class="section" id="unreal-engine-4">
<h4>Unreal Engine 4<a class="headerlink" href="#unreal-engine-4" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="https://forums.unrealengine.com/showthread.php?3539-Project-Paper2D">Paper2D</a>
provides built-in support for tile maps and tile sets, importing JSON
exported from Tiled.</li>
</ul>
</div>
<div class="section" id="urho3d">
<h4>Urho3D<a class="headerlink" href="#urho3d" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://urho3d.github.io/">Urho3D</a> natively supports loading Tiled
maps as part of the
<a class="reference external" href="http://urho3d.github.io/documentation/1.4/_urho2_d.html">Urho2D</a>
sublibrary
(<a class="reference external" href="http://urho3d.github.io/documentation/1.4/class_urho3_d_1_1_tile_map2_d.html">Documentation</a>,
<a class="reference external" href="http://urho3d.github.io/samples/36_Urho2DTileMap.html">HTML5
example</a>).</li>
</ul>
</div>
<div class="section" id="xna">
<h4>XNA<a class="headerlink" href="#xna" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference external" href="http://flatredball.com/">FlatRedBall</a> Glue tool ships with a
<a class="reference external" href="http://flatredball.com/documentation/tools/tiled-plugin/">Tiled plugin</a>
that loads TMX maps into the FlatRedBall engine, providing rich integration with its features.</li>
<li><a class="reference external" href="https://bitbucket.org/vinull/xtiled">XTiled</a> by Michael C. Neel
and Dylan Wolf, XNA library for loading and rendering TMX maps</li>
<li><a class="reference external" href="https://github.com/zachmu/tiled-xna">XNA map loader</a> by Kevin
Gadd, extended by Stephen Belanger and Zach Musgrave</li>
</ul>
</div>
</div>
</div>
<span id="document-reference/tmx-map-format"></span><div class="section" id="tmx-map-format">
<h2>TMX Map Format<a class="headerlink" href="#tmx-map-format" title="Permalink to this headline">¶</a></h2>
<p><strong>Version 1.4</strong></p>
<p>TMX and TSX are <a class="reference external" href="http://www.mapeditor.org">Tiled</a>’s own formats for storing
tile maps and tilesets, based on XML. TMX provides a flexible way to describe a
tile based map. It can describe maps with any tile size, any amount of
layers, any number of tile sets and it allows custom properties to be
set on most elements. Beside tile layers, it can also contain groups of
objects that can be placed freely.</p>
<p>Note that there are many <a class="reference internal" href="index.html#document-reference/support-for-tmx-maps"><span class="doc">libraries and frameworks</span></a>
available that can work with TMX maps and TSX tilesets.</p>
<p>In this document we’ll go through each element found in these file formats.
The elements are mentioned in the headers and the list of attributes of
the elements are listed right below, followed by a short explanation.
Attributes or elements that are deprecated or unsupported by the current
version of Tiled are formatted in italics. All optional attributes are
either marked as optional, or have a default value to imply that they are
optional.</p>
<p>Have a look at the <a class="reference internal" href="index.html#document-reference/tmx-changelog"><span class="doc">changelog</span></a> when you’re interested
in what changed between Tiled versions.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">A DTD-file (Document Type Definition) is served at
<a class="reference external" href="http://mapeditor.org/dtd/1.0/map.dtd">http://mapeditor.org/dtd/1.0/map.dtd</a>. This file is not up-to-date but might
be useful for XML-namespacing anyway.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">For compatibility reasons, it is recommended to ignore unknown elements and
attributes (or raise a warning). This makes it easier to add features
without breaking backwards compatibility, and allows custom variants and
additions to work with existing tools.</p>
</div>
<div class="section" id="map">
<span id="tmx-map"></span><h3>&lt;map&gt;<a class="headerlink" href="#map" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><strong>version:</strong> The TMX format version. Was “1.0” so far, and will be
incremented to match minor Tiled releases.</li>
<li><strong>tiledversion:</strong> The Tiled version used to save the file (since Tiled
1.0.1). May be a date (for snapshot builds). (optional)</li>
<li><strong>orientation:</strong> Map orientation. Tiled supports “orthogonal”,
“isometric”, “staggered” and “hexagonal” (since 0.11).</li>
<li><strong>renderorder:</strong> The order in which tiles on tile layers are rendered.
Valid values are <code class="docutils literal notranslate"><span class="pre">right-down</span></code> (the default), <code class="docutils literal notranslate"><span class="pre">right-up</span></code>,
<code class="docutils literal notranslate"><span class="pre">left-down</span></code> and <code class="docutils literal notranslate"><span class="pre">left-up</span></code>. In all cases, the map is drawn
row-by-row. (only supported for orthogonal maps at the moment)</li>
<li><strong>compressionlevel:</strong> The compression level to use for tile layer data
(defaults to -1, which means to use the algorithm default).</li>
<li><strong>width:</strong> The map width in tiles.</li>
<li><strong>height:</strong> The map height in tiles.</li>
<li><strong>tilewidth:</strong> The width of a tile.</li>
<li><strong>tileheight:</strong> The height of a tile.</li>
<li><strong>hexsidelength:</strong> Only for hexagonal maps. Determines the width or
height (depending on the staggered axis) of the tile’s edge, in
pixels.</li>
<li><strong>staggeraxis:</strong> For staggered and hexagonal maps, determines which axis
(“x” or “y”) is staggered. (since 0.11)</li>
<li><strong>staggerindex:</strong> For staggered and hexagonal maps, determines whether
the “even” or “odd” indexes along the staggered axis are shifted.
(since 0.11)</li>
<li><strong>backgroundcolor:</strong> The background color of the map. (optional, may
include alpha value since 0.15 in the form <code class="docutils literal notranslate"><span class="pre">#AARRGGBB</span></code>. Defaults to
fully transparent.)</li>
<li><strong>nextlayerid:</strong> Stores the next available ID for new layers. This
number is stored to prevent reuse of the same ID after layers have
been removed. (since 1.2) (defaults to the highest layer id in the file
+ 1)</li>
<li><strong>nextobjectid:</strong> Stores the next available ID for new objects. This
number is stored to prevent reuse of the same ID after objects have
been removed. (since 0.11) (defaults to the highest object id in the file
+ 1)</li>
<li><strong>infinite:</strong> Whether this map is infinite. An infinite map has no fixed
size and can grow in all directions. Its layer data is stored in chunks.
(<code class="docutils literal notranslate"><span class="pre">0</span></code> for false, <code class="docutils literal notranslate"><span class="pre">1</span></code> for true, defaults to 0)</li>
</ul>
<p>The <code class="docutils literal notranslate"><span class="pre">tilewidth</span></code> and <code class="docutils literal notranslate"><span class="pre">tileheight</span></code> properties determine the general
grid size of the map. The individual tiles may have different sizes.
Larger tiles will extend at the top and right (anchored to the bottom
left).</p>
<p>A map contains three different kinds of layers. Tile layers were once
the only type, and are simply called <code class="docutils literal notranslate"><span class="pre">layer</span></code>, object layers have the
<code class="docutils literal notranslate"><span class="pre">objectgroup</span></code> tag and image layers use the <code class="docutils literal notranslate"><span class="pre">imagelayer</span></code> tag. The
order in which these layers appear is the order in which the layers are
rendered by Tiled.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">staggered</span></code> orientation refers to an isometric map using staggered
axes.</p>
<p>Can contain at most one: <a class="reference internal" href="#tmx-properties"><span class="std std-ref">&lt;properties&gt;</span></a></p>
<p>Can contain any number: <a class="reference internal" href="#tmx-tileset"><span class="std std-ref">&lt;tileset&gt;</span></a>, <a class="reference internal" href="#tmx-layer"><span class="std std-ref">&lt;layer&gt;</span></a>,
<a class="reference internal" href="#tmx-objectgroup"><span class="std std-ref">&lt;objectgroup&gt;</span></a>, <a class="reference internal" href="#tmx-imagelayer"><span class="std std-ref">&lt;imagelayer&gt;</span></a>, <a class="reference internal" href="#tmx-group"><span class="std std-ref">&lt;group&gt;</span></a> (since 1.0),
<a class="reference internal" href="#tmx-editorsettings"><span class="std std-ref">&lt;editorsettings&gt;</span></a> (since 1.3)</p>
</div>
<div class="section" id="editorsettings">
<span id="tmx-editorsettings"></span><h3>&lt;editorsettings&gt;<a class="headerlink" href="#editorsettings" title="Permalink to this headline">¶</a></h3>
<p>This element contains various editor-specific settings, which are generally
not relevant when reading a map.</p>
<p>Can contain: <a class="reference internal" href="#tmx-chunksize"><span class="std std-ref">&lt;chunksize&gt;</span></a>, <a class="reference internal" href="#tmx-export"><span class="std std-ref">&lt;export&gt;</span></a></p>
<div class="section" id="chunksize">
<span id="tmx-chunksize"></span><h4>&lt;chunksize&gt;<a class="headerlink" href="#chunksize" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>width:</strong> The width of chunks used for infinite maps (default to 16).</li>
<li><strong>height:</strong> The width of chunks used for infinite maps (default to 16).</li>
</ul>
</div>
<div class="section" id="export">
<span id="tmx-export"></span><h4>&lt;export&gt;<a class="headerlink" href="#export" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>target:</strong> The last file this map was exported to.</li>
<li><strong>format:</strong> The short name of the last format this map was exported as.</li>
</ul>
</div>
</div>
<div class="section" id="tileset">
<span id="tmx-tileset"></span><h3>&lt;tileset&gt;<a class="headerlink" href="#tileset" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><strong>firstgid:</strong> The first global tile ID of this tileset (this global ID
maps to the first tile in this tileset).</li>
<li><strong>source:</strong> If this tileset is stored in an external TSX (Tile Set XML)
file, this attribute refers to that file. That TSX file has the same
structure as the <code class="docutils literal notranslate"><span class="pre">&lt;tileset&gt;</span></code> element described here. (There is the
firstgid attribute missing and this source attribute is also not
there. These two attributes are kept in the TMX map, since they are
map specific.)</li>
<li><strong>name:</strong> The name of this tileset.</li>
<li><strong>tilewidth:</strong> The (maximum) width of the tiles in this tileset.</li>
<li><strong>tileheight:</strong> The (maximum) height of the tiles in this tileset.</li>
<li><strong>spacing:</strong> The spacing in pixels between the tiles in this tileset
(applies to the tileset image, defaults to 0)</li>
<li><strong>margin:</strong> The margin around the tiles in this tileset (applies to the
tileset image, defaults to 0)</li>
<li><strong>tilecount:</strong> The number of tiles in this tileset (since 0.13)</li>
<li><strong>columns:</strong> The number of tile columns in the tileset. For image
collection tilesets it is editable and is used when displaying the
tileset. (since 0.15)</li>
<li><strong>objectalignment:</strong> Controls the alignment for tile objects.
Valid values are <code class="docutils literal notranslate"><span class="pre">unspecified</span></code>, <code class="docutils literal notranslate"><span class="pre">topleft</span></code>, <code class="docutils literal notranslate"><span class="pre">top</span></code>, <code class="docutils literal notranslate"><span class="pre">topright</span></code>,
<code class="docutils literal notranslate"><span class="pre">left</span></code>, <code class="docutils literal notranslate"><span class="pre">center</span></code>, <code class="docutils literal notranslate"><span class="pre">right</span></code>, <code class="docutils literal notranslate"><span class="pre">bottomleft</span></code>, <code class="docutils literal notranslate"><span class="pre">bottom</span></code> and
<code class="docutils literal notranslate"><span class="pre">bottomright</span></code>. The default value is <code class="docutils literal notranslate"><span class="pre">unspecified</span></code>, for compatibility
reasons. When unspecified, tile objects use <code class="docutils literal notranslate"><span class="pre">bottomleft</span></code> in orthogonal mode
and <code class="docutils literal notranslate"><span class="pre">bottom</span></code> in isometric mode. (since 1.4)</li>
</ul>
<p>If there are multiple <code class="docutils literal notranslate"><span class="pre">&lt;tileset&gt;</span></code> elements, they are in ascending
order of their <code class="docutils literal notranslate"><span class="pre">firstgid</span></code> attribute. The first tileset always has a
<code class="docutils literal notranslate"><span class="pre">firstgid</span></code> value of 1. Since Tiled 0.15, image collection tilesets do
not necessarily number their tiles consecutively since gaps can occur
when removing tiles.</p>
<p>Image collection tilesets have no <code class="docutils literal notranslate"><span class="pre">&lt;image&gt;</span></code> tag. Instead, each tile has
an <code class="docutils literal notranslate"><span class="pre">&lt;image&gt;</span></code> tag.</p>
<p>Can contain at most one: <a class="reference internal" href="#tmx-image"><span class="std std-ref">&lt;image&gt;</span></a>, <a class="reference internal" href="#tmx-tileoffset"><span class="std std-ref">&lt;tileoffset&gt;</span></a>,
<a class="reference internal" href="#tmx-grid"><span class="std std-ref">&lt;grid&gt;</span></a> (since 1.0), <a class="reference internal" href="#tmx-properties"><span class="std std-ref">&lt;properties&gt;</span></a>, <a class="reference internal" href="#tmx-terraintypes"><span class="std std-ref">&lt;terraintypes&gt;</span></a>,
<a class="reference internal" href="#tmx-wangsets"><span class="std std-ref">&lt;wangsets&gt;</span></a> (since 1.1),</p>
<p>Can contain any number: <a class="reference internal" href="#tmx-tileset-tile"><span class="std std-ref">&lt;tile&gt;</span></a></p>
<div class="section" id="tileoffset">
<span id="tmx-tileoffset"></span><h4>&lt;tileoffset&gt;<a class="headerlink" href="#tileoffset" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>x:</strong> Horizontal offset in pixels. (defaults to 0)</li>
<li><strong>y:</strong> Vertical offset in pixels (positive is down, defaults to 0)</li>
</ul>
<p>This element is used to specify an offset in pixels, to be applied when
drawing a tile from the related tileset. When not present, no offset is
applied.</p>
</div>
<div class="section" id="grid">
<span id="tmx-grid"></span><h4>&lt;grid&gt;<a class="headerlink" href="#grid" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>orientation:</strong> Orientation of the grid for the tiles in this
tileset (<code class="docutils literal notranslate"><span class="pre">orthogonal</span></code> or <code class="docutils literal notranslate"><span class="pre">isometric</span></code>, defaults to <code class="docutils literal notranslate"><span class="pre">orthogonal</span></code>)</li>
<li><strong>width:</strong> Width of a grid cell</li>
<li><strong>height:</strong> Height of a grid cell</li>
</ul>
<p>This element is only used in case of isometric orientation, and
determines how tile overlays for terrain and collision information are
rendered.</p>
</div>
<div class="section" id="image">
<span id="tmx-image"></span><h4>&lt;image&gt;<a class="headerlink" href="#image" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>format:</strong> Used for embedded images, in combination with a <code class="docutils literal notranslate"><span class="pre">data</span></code>
child element. Valid values are file extensions like <code class="docutils literal notranslate"><span class="pre">png</span></code>,
<code class="docutils literal notranslate"><span class="pre">gif</span></code>, <code class="docutils literal notranslate"><span class="pre">jpg</span></code>, <code class="docutils literal notranslate"><span class="pre">bmp</span></code>, etc.</li>
<li><em>id:</em> Used by some versions of Tiled Java. Deprecated and unsupported.</li>
<li><strong>source:</strong> The reference to the tileset image file (Tiled supports most
common image formats). Only used if the image is not embedded.</li>
<li><strong>trans:</strong> Defines a specific color that is treated as transparent
(example value: “#FF00FF” for magenta). Including the “#” is optional
and Tiled leaves it out for compatibility reasons. (optional)</li>
<li><strong>width:</strong> The image width in pixels (optional, used for tile index
correction when the image changes)</li>
<li><strong>height:</strong> The image height in pixels (optional)</li>
</ul>
<p>Note that it is not currently possible to use Tiled to create maps with
embedded image data, even though the TMX format supports this. It is
possible to create such maps using <code class="docutils literal notranslate"><span class="pre">libtiled</span></code> (Qt/C++) or
<a class="reference external" href="https://pypi.python.org/pypi/tmxlib">tmxlib</a> (Python).</p>
<p>Can contain at most one: <a class="reference internal" href="#tmx-data"><span class="std std-ref">&lt;data&gt;</span></a></p>
</div>
<div class="section" id="terraintypes">
<span id="tmx-terraintypes"></span><h4>&lt;terraintypes&gt;<a class="headerlink" href="#terraintypes" title="Permalink to this headline">¶</a></h4>
<p>This element defines an array of terrain types, which can be referenced
from the <code class="docutils literal notranslate"><span class="pre">terrain</span></code> attribute of the <code class="docutils literal notranslate"><span class="pre">tile</span></code> element.</p>
<p>Can contain any number: <a class="reference internal" href="#tmx-terrain"><span class="std std-ref">&lt;terrain&gt;</span></a></p>
<div class="section" id="terrain">
<span id="tmx-terrain"></span><h5>&lt;terrain&gt;<a class="headerlink" href="#terrain" title="Permalink to this headline">¶</a></h5>
<ul class="simple">
<li><strong>name:</strong> The name of the terrain type.</li>
<li><strong>tile:</strong> The local tile-id of the tile that represents the terrain
visually.</li>
</ul>
<p>Can contain at most one: <a class="reference internal" href="#tmx-properties"><span class="std std-ref">&lt;properties&gt;</span></a></p>
</div>
</div>
<div class="section" id="tile">
<span id="tmx-tileset-tile"></span><h4>&lt;tile&gt;<a class="headerlink" href="#tile" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>id:</strong> The local tile ID within its tileset.</li>
<li><strong>type:</strong> The type of the tile. Refers to an object type and is used
by tile objects. (optional) (since 1.0)</li>
<li><strong>terrain:</strong> Defines the terrain type of each corner of the tile,
given as comma-separated indexes in the terrain types array in the
order top-left, top-right, bottom-left, bottom-right. Leaving out a
value means that corner has no terrain. (optional)</li>
<li><strong>probability:</strong> A percentage indicating the probability that this
tile is chosen when it competes with others while editing with the
terrain tool. (defaults to 0)</li>
</ul>
<p>Can contain at most one: <a class="reference internal" href="#tmx-properties"><span class="std std-ref">&lt;properties&gt;</span></a>, <a class="reference internal" href="#tmx-image"><span class="std std-ref">&lt;image&gt;</span></a> (since
0.9), <a class="reference internal" href="#tmx-objectgroup"><span class="std std-ref">&lt;objectgroup&gt;</span></a>, <a class="reference internal" href="#tmx-animation"><span class="std std-ref">&lt;animation&gt;</span></a></p>
<div class="section" id="animation">
<span id="tmx-animation"></span><h5>&lt;animation&gt;<a class="headerlink" href="#animation" title="Permalink to this headline">¶</a></h5>
<p>Contains a list of animation frames.</p>
<p>Each tile can have exactly one animation associated with it. In the
future, there could be support for multiple named animations on a tile.</p>
<p>Can contain any number: <a class="reference internal" href="#tmx-frame"><span class="std std-ref">&lt;frame&gt;</span></a></p>
<div class="section" id="frame">
<span id="tmx-frame"></span><h6>&lt;frame&gt;<a class="headerlink" href="#frame" title="Permalink to this headline">¶</a></h6>
<ul class="simple">
<li><strong>tileid:</strong> The local ID of a tile within the parent
<a class="reference internal" href="#tmx-tileset"><span class="std std-ref">&lt;tileset&gt;</span></a>.</li>
<li><strong>duration:</strong> How long (in milliseconds) this frame should be displayed
before advancing to the next frame.</li>
</ul>
</div>
</div>
</div>
<div class="section" id="wangsets">
<span id="tmx-wangsets"></span><h4>&lt;wangsets&gt;<a class="headerlink" href="#wangsets" title="Permalink to this headline">¶</a></h4>
<p>Contains the list of Wang sets defined for this tileset.</p>
<p>Can contain any number: <a class="reference internal" href="#tmx-wangset"><span class="std std-ref">&lt;wangset&gt;</span></a></p>
<div class="section" id="wangset">
<span id="tmx-wangset"></span><h5>&lt;wangset&gt;<a class="headerlink" href="#wangset" title="Permalink to this headline">¶</a></h5>
<p>Defines a list of corner colors and a list of edge colors, and any
number of Wang tiles using these colors.</p>
<ul class="simple">
<li><strong>name:</strong> The name of the Wang set.</li>
<li><strong>tile:</strong> The tile ID of the tile representing this Wang set.</li>
</ul>
<p>Can contain at most one: <a class="reference internal" href="#tmx-properties"><span class="std std-ref">&lt;properties&gt;</span></a></p>
<p>Can contain up to 15 (each): <a class="reference internal" href="#tmx-wangcornercolor"><span class="std std-ref">&lt;wangcornercolor&gt;</span></a>, <a class="reference internal" href="#tmx-wangedgecolor"><span class="std std-ref">&lt;wangedgecolor&gt;</span></a></p>
<p>Can contain any number: <a class="reference internal" href="#tmx-wangtile"><span class="std std-ref">&lt;wangtile&gt;</span></a></p>
<div class="section" id="wangcornercolor">
<span id="tmx-wangcornercolor"></span><h6>&lt;wangcornercolor&gt;<a class="headerlink" href="#wangcornercolor" title="Permalink to this headline">¶</a></h6>
<p>A color that can be used to define the corner of a Wang tile.</p>
<ul class="simple">
<li><strong>name:</strong> The name of this color.</li>
<li><strong>color:</strong> The color in <code class="docutils literal notranslate"><span class="pre">#RRGGBB</span></code> format (example: <code class="docutils literal notranslate"><span class="pre">#c17d11</span></code>).</li>
<li><strong>tile:</strong> The tile ID of the tile representing this color.</li>
<li><strong>probability:</strong> The relative probability that this color is chosen
over others in case of multiple options. (defaults to 0)</li>
</ul>
</div>
<div class="section" id="wangedgecolor">
<span id="tmx-wangedgecolor"></span><h6>&lt;wangedgecolor&gt;<a class="headerlink" href="#wangedgecolor" title="Permalink to this headline">¶</a></h6>
<p>A color that can be used to define the edge of a Wang tile.</p>
<ul class="simple">
<li><strong>name:</strong> The name of this color.</li>
<li><strong>color:</strong> The color in <code class="docutils literal notranslate"><span class="pre">#RRGGBB</span></code> format (example: <code class="docutils literal notranslate"><span class="pre">#c17d11</span></code>).</li>
<li><strong>tile:</strong> The tile ID of the tile representing this color.</li>
<li><strong>probability:</strong> The relative probability that this color is chosen
over others in case of multiple options. (defaults to 0)</li>
</ul>
</div>
<div class="section" id="wangtile">
<span id="tmx-wangtile"></span><h6>&lt;wangtile&gt;<a class="headerlink" href="#wangtile" title="Permalink to this headline">¶</a></h6>
<p>Defines a Wang tile, by referring to a tile in the tileset and
associating it with a certain Wang ID.</p>
<ul class="simple">
<li><strong>tileid:</strong> The tile ID.</li>
<li><strong>wangid:</strong> The Wang ID, which is a 32-bit unsigned integer stored
in the format <code class="docutils literal notranslate"><span class="pre">0xCECECECE</span></code> (where each C is a corner color and
each E is an edge color, from right to left clockwise, starting with
the top edge)</li>
<li><strong>hflip:</strong> Whether the tile is flipped horizontally. This only affects
the tile image, it does not change the meaning of the wangid. See
<a class="reference internal" href="#tmx-tile-flipping"><span class="std std-ref">Tile flipping</span></a> for more info. (defaults to false)</li>
<li><strong>vflip:</strong> Whether the tile is flipped vertically. This only affects
the tile image, it does not change the meaning of the wangid. See
<a class="reference internal" href="#tmx-tile-flipping"><span class="std std-ref">Tile flipping</span></a> for more info. (defaults to false)</li>
<li><strong>dflip:</strong> Whether the tile is flipped on its diagonal. This only affects
the tile image, it does not change the meaning of the wangid. See
<a class="reference internal" href="#tmx-tile-flipping"><span class="std std-ref">Tile flipping</span></a> for more info. (defaults to false)</li>
</ul>
</div>
</div>
</div>
</div>
<div class="section" id="layer">
<span id="tmx-layer"></span><h3>&lt;layer&gt;<a class="headerlink" href="#layer" title="Permalink to this headline">¶</a></h3>
<p>All <a class="reference internal" href="#tmx-tileset"><span class="std std-ref">&lt;tileset&gt;</span></a> tags shall occur before the first <a class="reference internal" href="#tmx-layer"><span class="std std-ref">&lt;layer&gt;</span></a> tag
so that parsers may rely on having the tilesets before needing to resolve
tiles.</p>
<ul class="simple">
<li><strong>id:</strong> Unique ID of the layer. Each layer that added to a map gets
a unique id. Even if a layer is deleted, no layer ever gets the same
ID. Can not be changed in Tiled. (since Tiled 1.2)</li>
<li><strong>name:</strong> The name of the layer. (defaults to “”)</li>
<li><em>x:</em> The x coordinate of the layer in tiles. Defaults to 0 and can not be changed in Tiled.</li>
<li><em>y:</em> The y coordinate of the layer in tiles. Defaults to 0 and can not be changed in Tiled.</li>
<li><strong>width:</strong> The width of the layer in tiles. Always the same as the map width for fixed-size maps.</li>
<li><strong>height:</strong> The height of the layer in tiles. Always the same as the map height for fixed-size maps.</li>
<li><strong>opacity:</strong> The opacity of the layer as a value from 0 to 1. Defaults to 1.</li>
<li><strong>visible:</strong> Whether the layer is shown (1) or hidden (0). Defaults to 1.</li>
<li><strong>tintcolor:</strong> A color that is multiplied with any tiles drawn by this layer in <code class="docutils literal notranslate"><span class="pre">#AARRGGBB</span></code> or <code class="docutils literal notranslate"><span class="pre">#RRGGBB</span></code> format (optional).</li>
<li><strong>offsetx:</strong> Horizontal offset for this layer in pixels. Defaults to 0.
(since 0.14)</li>
<li><strong>offsety:</strong> Vertical offset for this layer in pixels. Defaults to 0.
(since 0.14)</li>
</ul>
<p>Can contain at most one: <a class="reference internal" href="#tmx-properties"><span class="std std-ref">&lt;properties&gt;</span></a>, <a class="reference internal" href="#tmx-data"><span class="std std-ref">&lt;data&gt;</span></a></p>
<div class="section" id="data">
<span id="tmx-data"></span><h4>&lt;data&gt;<a class="headerlink" href="#data" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>encoding:</strong> The encoding used to encode the tile layer data. When used,
it can be “base64” and “csv” at the moment. (optional)</li>
<li><strong>compression:</strong> The compression used to compress the tile layer data.
Tiled supports “gzip”, “zlib” and (as a compile-time option since Tiled 1.3)
“zstd”.</li>
</ul>
<p>When no encoding or compression is given, the tiles are stored as
individual XML <code class="docutils literal notranslate"><span class="pre">tile</span></code> elements. Next to that, the easiest format to
parse is the “csv” (comma separated values) format.</p>
<p>The base64-encoded and optionally compressed layer data is somewhat more
complicated to parse. First you need to base64-decode it, then you may
need to decompress it. Now you have an array of bytes, which should be
interpreted as an array of unsigned 32-bit integers using little-endian
byte ordering.</p>
<p>Whatever format you choose for your layer data, you will always end up
with so called “global tile IDs” (gids). They are global, since they may
refer to a tile from any of the tilesets used by the map. In order to
find out from which tileset the tile is you need to find the tileset
with the highest <code class="docutils literal notranslate"><span class="pre">firstgid</span></code> that is still lower or equal than the gid.
The tilesets are always stored with increasing <code class="docutils literal notranslate"><span class="pre">firstgid</span></code>s.</p>
<p>Can contain any number: <a class="reference internal" href="#tmx-tilelayer-tile"><span class="std std-ref">&lt;tile&gt;</span></a>, <a class="reference internal" href="#tmx-chunk"><span class="std std-ref">&lt;chunk&gt;</span></a></p>
<div class="section" id="tile-flipping">
<span id="tmx-tile-flipping"></span><h5>Tile flipping<a class="headerlink" href="#tile-flipping" title="Permalink to this headline">¶</a></h5>
<p>The highest three bits of the gid store the flipped states. Bit 32 is
used for storing whether the tile is horizontally flipped, bit 31 is
used for the vertically flipped tiles and bit 30 indicates whether the
tile is flipped (anti) diagonally, enabling tile rotation. These bits
have to be read and cleared before you can find out which tileset a tile
belongs to.</p>
<p>When rendering a tile, the order of operation matters. The diagonal flip
(x/y axis swap) is done first, followed by the horizontal and vertical
flips.</p>
<p>The following C++ pseudo-code should make it all clear:</p>
<div class="code cpp highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">Bits</span> <span class="n">on</span> <span class="n">the</span> <span class="n">far</span> <span class="n">end</span> <span class="n">of</span> <span class="n">the</span> <span class="mi">32</span><span class="o">-</span><span class="n">bit</span> <span class="k">global</span> <span class="n">tile</span> <span class="n">ID</span> <span class="n">are</span> <span class="n">used</span> <span class="k">for</span> <span class="n">tile</span> <span class="n">flags</span>
<span class="n">const</span> <span class="n">unsigned</span> <span class="n">FLIPPED_HORIZONTALLY_FLAG</span> <span class="o">=</span> <span class="mh">0x80000000</span><span class="p">;</span>
<span class="n">const</span> <span class="n">unsigned</span> <span class="n">FLIPPED_VERTICALLY_FLAG</span>   <span class="o">=</span> <span class="mh">0x40000000</span><span class="p">;</span>
<span class="n">const</span> <span class="n">unsigned</span> <span class="n">FLIPPED_DIAGONALLY_FLAG</span>   <span class="o">=</span> <span class="mh">0x20000000</span><span class="p">;</span>

<span class="o">...</span>

<span class="o">//</span> <span class="n">Extract</span> <span class="n">the</span> <span class="n">contents</span> <span class="n">of</span> <span class="n">the</span> <span class="o">&lt;</span><span class="n">data</span><span class="o">&gt;</span> <span class="n">element</span>
<span class="n">string</span> <span class="n">tile_data</span> <span class="o">=</span> <span class="o">...</span>

<span class="n">unsigned</span> <span class="n">char</span> <span class="o">*</span><span class="n">data</span> <span class="o">=</span> <span class="n">decompress</span><span class="p">(</span><span class="n">base64_decode</span><span class="p">(</span><span class="n">tile_data</span><span class="p">));</span>
<span class="n">unsigned</span> <span class="n">tile_index</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

<span class="o">//</span> <span class="n">Here</span> <span class="n">you</span> <span class="n">should</span> <span class="n">check</span> <span class="n">that</span> <span class="n">the</span> <span class="n">data</span> <span class="n">has</span> <span class="n">the</span> <span class="n">right</span> <span class="n">size</span>
<span class="o">//</span> <span class="p">(</span><span class="n">map_width</span> <span class="o">*</span> <span class="n">map_height</span> <span class="o">*</span> <span class="mi">4</span><span class="p">)</span>

<span class="k">for</span> <span class="p">(</span><span class="nb">int</span> <span class="n">y</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">y</span> <span class="o">&lt;</span> <span class="n">map_height</span><span class="p">;</span> <span class="o">++</span><span class="n">y</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">for</span> <span class="p">(</span><span class="nb">int</span> <span class="n">x</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">x</span> <span class="o">&lt;</span> <span class="n">map_width</span><span class="p">;</span> <span class="o">++</span><span class="n">x</span><span class="p">)</span> <span class="p">{</span>
    <span class="n">unsigned</span> <span class="n">global_tile_id</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">tile_index</span><span class="p">]</span> <span class="o">|</span>
                              <span class="n">data</span><span class="p">[</span><span class="n">tile_index</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> <span class="o">&lt;&lt;</span> <span class="mi">8</span> <span class="o">|</span>
                              <span class="n">data</span><span class="p">[</span><span class="n">tile_index</span> <span class="o">+</span> <span class="mi">2</span><span class="p">]</span> <span class="o">&lt;&lt;</span> <span class="mi">16</span> <span class="o">|</span>
                              <span class="n">data</span><span class="p">[</span><span class="n">tile_index</span> <span class="o">+</span> <span class="mi">3</span><span class="p">]</span> <span class="o">&lt;&lt;</span> <span class="mi">24</span><span class="p">;</span>
    <span class="n">tile_index</span> <span class="o">+=</span> <span class="mi">4</span><span class="p">;</span>

    <span class="o">//</span> <span class="n">Read</span> <span class="n">out</span> <span class="n">the</span> <span class="n">flags</span>
    <span class="nb">bool</span> <span class="n">flipped_horizontally</span> <span class="o">=</span> <span class="p">(</span><span class="n">global_tile_id</span> <span class="o">&amp;</span> <span class="n">FLIPPED_HORIZONTALLY_FLAG</span><span class="p">);</span>
    <span class="nb">bool</span> <span class="n">flipped_vertically</span> <span class="o">=</span> <span class="p">(</span><span class="n">global_tile_id</span> <span class="o">&amp;</span> <span class="n">FLIPPED_VERTICALLY_FLAG</span><span class="p">);</span>
    <span class="nb">bool</span> <span class="n">flipped_diagonally</span> <span class="o">=</span> <span class="p">(</span><span class="n">global_tile_id</span> <span class="o">&amp;</span> <span class="n">FLIPPED_DIAGONALLY_FLAG</span><span class="p">);</span>

    <span class="o">//</span> <span class="n">Clear</span> <span class="n">the</span> <span class="n">flags</span>
    <span class="n">global_tile_id</span> <span class="o">&amp;=</span> <span class="o">~</span><span class="p">(</span><span class="n">FLIPPED_HORIZONTALLY_FLAG</span> <span class="o">|</span>
                        <span class="n">FLIPPED_VERTICALLY_FLAG</span> <span class="o">|</span>
                        <span class="n">FLIPPED_DIAGONALLY_FLAG</span><span class="p">);</span>

    <span class="o">//</span> <span class="n">Resolve</span> <span class="n">the</span> <span class="n">tile</span>
    <span class="k">for</span> <span class="p">(</span><span class="nb">int</span> <span class="n">i</span> <span class="o">=</span> <span class="n">tileset_count</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span> <span class="n">i</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">;</span> <span class="o">--</span><span class="n">i</span><span class="p">)</span> <span class="p">{</span>
      <span class="n">Tileset</span> <span class="o">*</span><span class="n">tileset</span> <span class="o">=</span> <span class="n">tilesets</span><span class="p">[</span><span class="n">i</span><span class="p">];</span>

      <span class="k">if</span> <span class="p">(</span><span class="n">tileset</span><span class="o">-&gt;</span><span class="n">first_gid</span><span class="p">()</span> <span class="o">&lt;=</span> <span class="n">global_tile_id</span><span class="p">)</span> <span class="p">{</span>
        <span class="n">tiles</span><span class="p">[</span><span class="n">y</span><span class="p">][</span><span class="n">x</span><span class="p">]</span> <span class="o">=</span> <span class="n">tileset</span><span class="o">-&gt;</span><span class="n">tileAt</span><span class="p">(</span><span class="n">global_tile_id</span> <span class="o">-</span> <span class="n">tileset</span><span class="o">-&gt;</span><span class="n">first_gid</span><span class="p">());</span>
        <span class="k">break</span><span class="p">;</span>
      <span class="p">}</span>
    <span class="p">}</span>
  <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>(Since the above code was put together on this wiki page and can’t be
directly tested, please make sure to report any errors you encounter
when basing your parsing code on it, thanks.)</p>
</div>
</div>
<div class="section" id="chunk">
<span id="tmx-chunk"></span><h4>&lt;chunk&gt;<a class="headerlink" href="#chunk" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>x:</strong> The x coordinate of the chunk in tiles.</li>
<li><strong>y:</strong> The y coordinate of the chunk in tiles.</li>
<li><strong>width:</strong> The width of the chunk in tiles.</li>
<li><strong>height:</strong> The height of the chunk in tiles.</li>
</ul>
<p>This is currently added only for infinite maps. The contents of a chunk
element is same as that of the <code class="docutils literal notranslate"><span class="pre">data</span></code> element, except it stores the
data of the area specified in the attributes.</p>
<p>Can contain any number: <a class="reference internal" href="#tmx-tilelayer-tile"><span class="std std-ref">&lt;tile&gt;</span></a></p>
</div>
<div class="section" id="tmx-tilelayer-tile">
<span id="id1"></span><h4>&lt;tile&gt;<a class="headerlink" href="#tmx-tilelayer-tile" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>gid:</strong> The global tile ID (default: 0).</li>
</ul>
<p>Not to be confused with the <code class="docutils literal notranslate"><span class="pre">tile</span></code> element inside a <code class="docutils literal notranslate"><span class="pre">tileset</span></code>, this
element defines the value of a single tile on a tile layer. This is
however the most inefficient way of storing the tile layer data, and
should generally be avoided.</p>
</div>
</div>
<div class="section" id="objectgroup">
<span id="tmx-objectgroup"></span><h3>&lt;objectgroup&gt;<a class="headerlink" href="#objectgroup" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><strong>id:</strong> Unique ID of the layer. Each layer that added to a map gets
a unique id. Even if a layer is deleted, no layer ever gets the same
ID. Can not be changed in Tiled. (since Tiled 1.2)</li>
<li><strong>name:</strong> The name of the object group. (defaults to “”)</li>
<li><strong>color:</strong> The color used to display the objects in this group. (defaults
to gray (“#a0a0a4”))</li>
<li><em>x:</em> The x coordinate of the object group in tiles. Defaults to 0 and
can no longer be changed in Tiled.</li>
<li><em>y:</em> The y coordinate of the object group in tiles. Defaults to 0 and
can no longer be changed in Tiled.</li>
<li><em>width:</em> The width of the object group in tiles. Meaningless.</li>
<li><em>height:</em> The height of the object group in tiles. Meaningless.</li>
<li><strong>opacity:</strong> The opacity of the layer as a value from 0 to 1. (defaults to
1)</li>
<li><strong>visible:</strong> Whether the layer is shown (1) or hidden (0). (defaults to 1)</li>
<li><strong>tintcolor:</strong> A color that is multiplied with any tile objects drawn by this layer, in <code class="docutils literal notranslate"><span class="pre">#AARRGGBB</span></code> or <code class="docutils literal notranslate"><span class="pre">#RRGGBB</span></code> format (optional).</li>
<li><strong>offsetx:</strong> Horizontal offset for this object group in pixels. (defaults
to 0) (since 0.14)</li>
<li><strong>offsety:</strong> Vertical offset for this object group in pixels. (defaults
to 0) (since 0.14)</li>
<li><strong>draworder:</strong> Whether the objects are drawn according to the order of
appearance (“index”) or sorted by their y-coordinate (“topdown”).
(defaults to “topdown”)</li>
</ul>
<p>The object group is in fact a map layer, and is hence called “object
layer” in Tiled.</p>
<p>Can contain at most one: <a class="reference internal" href="#tmx-properties"><span class="std std-ref">&lt;properties&gt;</span></a></p>
<p>Can contain any number: <a class="reference internal" href="#tmx-object"><span class="std std-ref">&lt;object&gt;</span></a></p>
<div class="section" id="object">
<span id="tmx-object"></span><h4>&lt;object&gt;<a class="headerlink" href="#object" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>id:</strong> Unique ID of the object. Each object that is placed on a map gets
a unique id. Even if an object was deleted, no object gets the same
ID. Can not be changed in Tiled. (since Tiled 0.11)</li>
<li><strong>name:</strong> The name of the object. An arbitrary string. (defaults to “”)</li>
<li><strong>type:</strong> The type of the object. An arbitrary string. (defaults to “”)</li>
<li><strong>x:</strong> The x coordinate of the object in pixels. (defaults to 0)</li>
<li><strong>y:</strong> The y coordinate of the object in pixels. (defaults to 0)</li>
<li><strong>width:</strong> The width of the object in pixels. (defaults to 0)</li>
<li><strong>height:</strong> The height of the object in pixels. (defaults to 0)</li>
<li><strong>rotation:</strong> The rotation of the object in degrees clockwise around (x, y).
(defaults to 0)</li>
<li><strong>gid:</strong> A reference to a tile. (optional)</li>
<li><strong>visible:</strong> Whether the object is shown (1) or hidden (0). (defaults to
1)</li>
<li><strong>template:</strong> A reference to a <a class="reference internal" href="#tmx-template-files"><span class="std std-ref">template file</span></a>. (optional)</li>
</ul>
<p>While tile layers are very suitable for anything repetitive aligned to
the tile grid, sometimes you want to annotate your map with other
information, not necessarily aligned to the grid. Hence the objects have
their coordinates and size in pixels, but you can still easily align
that to the grid when you want to.</p>
<p>You generally use objects to add custom information to your tile map,
such as spawn points, warps, exits, etc.</p>
<p>When the object has a <code class="docutils literal notranslate"><span class="pre">gid</span></code> set, then it is represented by the image
of the tile with that global ID. The image alignment currently depends
on the map orientation. In orthogonal orientation it’s aligned to the
bottom-left while in isometric it’s aligned to the bottom-center. The
image will rotate around the bottom-left or bottom-center, respectively.</p>
<p>When the object has a <code class="docutils literal notranslate"><span class="pre">template</span></code> set, it will borrow all the
properties from the specified template, properties saved with the object
will have higher priority, i.e. they will override the template
properties.</p>
<p>Can contain at most one: <a class="reference internal" href="#tmx-properties"><span class="std std-ref">&lt;properties&gt;</span></a>, <a class="reference internal" href="#tmx-ellipse"><span class="std std-ref">&lt;ellipse&gt;</span></a> (since
0.9), <a class="reference internal" href="#tmx-point"><span class="std std-ref">&lt;point&gt;</span></a> (since 1.1), <a class="reference internal" href="#tmx-polygon"><span class="std std-ref">&lt;polygon&gt;</span></a>, <a class="reference internal" href="#tmx-polyline"><span class="std std-ref">&lt;polyline&gt;</span></a>,
<a class="reference internal" href="#tmx-text"><span class="std std-ref">&lt;text&gt;</span></a> (since 1.0)</p>
</div>
<div class="section" id="ellipse">
<span id="tmx-ellipse"></span><h4>&lt;ellipse&gt;<a class="headerlink" href="#ellipse" title="Permalink to this headline">¶</a></h4>
<p>Used to mark an object as an ellipse. The existing <code class="docutils literal notranslate"><span class="pre">x</span></code>, <code class="docutils literal notranslate"><span class="pre">y</span></code>,
<code class="docutils literal notranslate"><span class="pre">width</span></code> and <code class="docutils literal notranslate"><span class="pre">height</span></code> attributes are used to determine the size of
the ellipse.</p>
</div>
<div class="section" id="point">
<span id="tmx-point"></span><h4>&lt;point&gt;<a class="headerlink" href="#point" title="Permalink to this headline">¶</a></h4>
<p>Used to mark an object as a point. The existing <code class="docutils literal notranslate"><span class="pre">x</span></code> and <code class="docutils literal notranslate"><span class="pre">y</span></code> attributes
are used to determine the position of the point.</p>
</div>
<div class="section" id="polygon">
<span id="tmx-polygon"></span><h4>&lt;polygon&gt;<a class="headerlink" href="#polygon" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>points:</strong> A list of x,y coordinates in pixels.</li>
</ul>
<p>Each <code class="docutils literal notranslate"><span class="pre">polygon</span></code> object is made up of a space-delimited list of x,y
coordinates. The origin for these coordinates is the location of the
parent <code class="docutils literal notranslate"><span class="pre">object</span></code>. By default, the first point is created as 0,0
denoting that the point will originate exactly where the <code class="docutils literal notranslate"><span class="pre">object</span></code> is
placed.</p>
</div>
<div class="section" id="polyline">
<span id="tmx-polyline"></span><h4>&lt;polyline&gt;<a class="headerlink" href="#polyline" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>points:</strong> A list of x,y coordinates in pixels.</li>
</ul>
<p>A <code class="docutils literal notranslate"><span class="pre">polyline</span></code> follows the same placement definition as a <code class="docutils literal notranslate"><span class="pre">polygon</span></code>
object.</p>
</div>
<div class="section" id="text">
<span id="tmx-text"></span><h4>&lt;text&gt;<a class="headerlink" href="#text" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>fontfamily:</strong> The font family used (defaults to “sans-serif”)</li>
<li><strong>pixelsize:</strong> The size of the font in pixels (not using points,
because other sizes in the TMX format are also using pixels)
(defaults to 16)</li>
<li><strong>wrap:</strong> Whether word wrapping is enabled (1) or disabled (0).
(defaults to 0)</li>
<li><strong>color:</strong> Color of the text in <code class="docutils literal notranslate"><span class="pre">#AARRGGBB</span></code> or <code class="docutils literal notranslate"><span class="pre">#RRGGBB</span></code> format
(defaults to #000000)</li>
<li><strong>bold:</strong> Whether the font is bold (1) or not (0). (defaults to 0)</li>
<li><strong>italic:</strong> Whether the font is italic (1) or not (0). (defaults to 0)</li>
<li><strong>underline:</strong> Whether a line should be drawn below the text (1) or
not (0). (defaults to 0)</li>
<li><strong>strikeout:</strong> Whether a line should be drawn through the text (1) or
not (0). (defaults to 0)</li>
<li><strong>kerning:</strong> Whether kerning should be used while rendering the text
(1) or not (0). (defaults to 1)</li>
<li><strong>halign:</strong> Horizontal alignment of the text within the object
(<code class="docutils literal notranslate"><span class="pre">left</span></code>, <code class="docutils literal notranslate"><span class="pre">center</span></code>, <code class="docutils literal notranslate"><span class="pre">right</span></code> or <code class="docutils literal notranslate"><span class="pre">justify</span></code>, defaults to <code class="docutils literal notranslate"><span class="pre">left</span></code>)
(since Tiled 1.2.1)</li>
<li><strong>valign:</strong> Vertical alignment of the text within the object (<code class="docutils literal notranslate"><span class="pre">top</span></code>
, <code class="docutils literal notranslate"><span class="pre">center</span></code> or <code class="docutils literal notranslate"><span class="pre">bottom</span></code>, defaults to <code class="docutils literal notranslate"><span class="pre">top</span></code>)</li>
</ul>
<p>Used to mark an object as a text object. Contains the actual text as
character data.</p>
<p>For alignment purposes, the bottom of the text is the descender height of
the font, and the top of the text is the ascender height of the font. For
example, <code class="docutils literal notranslate"><span class="pre">bottom</span></code> alignment of the word “cat” will leave some space below
the text, even though it is unused for this word with most fonts. Similarly,
<code class="docutils literal notranslate"><span class="pre">top</span></code> alignment of the word “cat” will leave some space above the “t” with
most fonts, because this space is used for diacritics.</p>
<p>If the text is larger than the object’s bounds, it is clipped to the bounds
of the object.</p>
</div>
</div>
<div class="section" id="imagelayer">
<span id="tmx-imagelayer"></span><h3>&lt;imagelayer&gt;<a class="headerlink" href="#imagelayer" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><strong>id:</strong> Unique ID of the layer. Each layer that added to a map gets
a unique id. Even if a layer is deleted, no layer ever gets the same
ID. Can not be changed in Tiled. (since Tiled 1.2)</li>
<li><strong>name:</strong> The name of the image layer. (defaults to “”)</li>
<li><strong>offsetx:</strong> Horizontal offset of the image layer in pixels. (defaults to
0) (since 0.15)</li>
<li><strong>offsety:</strong> Vertical offset of the image layer in pixels. (defaults to
0) (since 0.15)</li>
<li><em>x:</em> The x position of the image layer in pixels. (defaults to 0, deprecated
since 0.15)</li>
<li><em>y:</em> The y position of the image layer in pixels. (defaults to 0, deprecated
since 0.15)</li>
<li><strong>opacity:</strong> The opacity of the layer as a value from 0 to 1. (defaults to
1)</li>
<li><strong>visible:</strong> Whether the layer is shown (1) or hidden (0). (defaults to 1)</li>
<li><strong>tintcolor:</strong> A color that is multiplied with the image drawn by this layer in <code class="docutils literal notranslate"><span class="pre">#AARRGGBB</span></code> or <code class="docutils literal notranslate"><span class="pre">#RRGGBB</span></code> format (optional).</li>
</ul>
<p>A layer consisting of a single image.</p>
<p>Can contain at most one: <a class="reference internal" href="#tmx-properties"><span class="std std-ref">&lt;properties&gt;</span></a>, <a class="reference internal" href="#tmx-image"><span class="std std-ref">&lt;image&gt;</span></a></p>
</div>
<div class="section" id="group">
<span id="tmx-group"></span><h3>&lt;group&gt;<a class="headerlink" href="#group" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><strong>id:</strong> Unique ID of the layer. Each layer that added to a map gets
a unique id. Even if a layer is deleted, no layer ever gets the same
ID. Can not be changed in Tiled. (since Tiled 1.2)</li>
<li><strong>name:</strong> The name of the group layer. (defaults to “”)</li>
<li><strong>offsetx:</strong> Horizontal offset of the group layer in pixels. (defaults to
0)</li>
<li><strong>offsety:</strong> Vertical offset of the group layer in pixels. (defaults to
0)</li>
<li><strong>opacity:</strong> The opacity of the layer as a value from 0 to 1. (defaults to
1)</li>
<li><strong>visible:</strong> Whether the layer is shown (1) or hidden (0). (defaults to 1)</li>
<li><strong>tintcolor:</strong> A color that is multiplied with any graphics drawn by any child layers, in <code class="docutils literal notranslate"><span class="pre">#AARRGGBB</span></code> or <code class="docutils literal notranslate"><span class="pre">#RRGGBB</span></code> format (optional).</li>
</ul>
<p>A group layer, used to organize the layers of the map in a hierarchy.
Its attributes <code class="docutils literal notranslate"><span class="pre">offsetx</span></code>, <code class="docutils literal notranslate"><span class="pre">offsety</span></code>, <code class="docutils literal notranslate"><span class="pre">opacity</span></code>, <code class="docutils literal notranslate"><span class="pre">visible</span></code> and
<code class="docutils literal notranslate"><span class="pre">tintcolor</span></code> recursively affect child layers.</p>
<p>Can contain at most one: <a class="reference internal" href="#tmx-properties"><span class="std std-ref">&lt;properties&gt;</span></a></p>
<p>Can contain any number: <a class="reference internal" href="#tmx-layer"><span class="std std-ref">&lt;layer&gt;</span></a>,
<a class="reference internal" href="#tmx-objectgroup"><span class="std std-ref">&lt;objectgroup&gt;</span></a>, <a class="reference internal" href="#tmx-imagelayer"><span class="std std-ref">&lt;imagelayer&gt;</span></a>, <a class="reference internal" href="#tmx-group"><span class="std std-ref">&lt;group&gt;</span></a></p>
</div>
<div class="section" id="properties">
<span id="tmx-properties"></span><h3>&lt;properties&gt;<a class="headerlink" href="#properties" title="Permalink to this headline">¶</a></h3>
<p>Wraps any number of custom properties. Can be used as a child of the
<code class="docutils literal notranslate"><span class="pre">map</span></code>, <code class="docutils literal notranslate"><span class="pre">tileset</span></code>, <code class="docutils literal notranslate"><span class="pre">tile</span></code> (when part of a <code class="docutils literal notranslate"><span class="pre">tileset</span></code>),
<code class="docutils literal notranslate"><span class="pre">terrain</span></code>, <code class="docutils literal notranslate"><span class="pre">layer</span></code>, <code class="docutils literal notranslate"><span class="pre">objectgroup</span></code>, <code class="docutils literal notranslate"><span class="pre">object</span></code>, <code class="docutils literal notranslate"><span class="pre">imagelayer</span></code> and
<code class="docutils literal notranslate"><span class="pre">group</span></code> elements.</p>
<p>Can contain any number: <a class="reference internal" href="#tmx-property"><span class="std std-ref">&lt;property&gt;</span></a></p>
<div class="section" id="property">
<span id="tmx-property"></span><h4>&lt;property&gt;<a class="headerlink" href="#property" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><strong>name:</strong> The name of the property.</li>
<li><strong>type:</strong> The type of the property. Can be <code class="docutils literal notranslate"><span class="pre">string</span></code> (default), <code class="docutils literal notranslate"><span class="pre">int</span></code>,
<code class="docutils literal notranslate"><span class="pre">float</span></code>, <code class="docutils literal notranslate"><span class="pre">bool</span></code>, <code class="docutils literal notranslate"><span class="pre">color</span></code>, <code class="docutils literal notranslate"><span class="pre">file</span></code> or <code class="docutils literal notranslate"><span class="pre">object</span></code> (since 0.16, with
<code class="docutils literal notranslate"><span class="pre">color</span></code> and <code class="docutils literal notranslate"><span class="pre">file</span></code> added in 0.17, and <code class="docutils literal notranslate"><span class="pre">object</span></code> added in 1.4).</li>
<li><strong>value:</strong> The value of the property. (default string is “”, default
number is 0, default boolean is “false”, default color is #00000000, default
file is “.” (the current file’s parent directory))</li>
</ul>
<p>Boolean properties have a value of either “true” or “false”.</p>
<p>Color properties are stored in the format <code class="docutils literal notranslate"><span class="pre">#AARRGGBB</span></code>.</p>
<p>File properties are stored as paths relative from the location of the
map file.</p>
<p>Object properties can reference any object on the same map and are stored as an
integer (the ID of the referenced object, or 0 when no object is referenced).
When used on objects in the Tile Collision Editor, they can only refer to
other objects on the same tile.</p>
<p>When a string property contains newlines, the current version of Tiled
will write out the value as characters contained inside the <code class="docutils literal notranslate"><span class="pre">property</span></code>
element rather than as the <code class="docutils literal notranslate"><span class="pre">value</span></code> attribute. It is possible that a
future version of the TMX format will switch to always saving property
values inside the element rather than as an attribute.</p>
</div>
</div>
<div class="section" id="template-files">
<span id="tmx-template-files"></span><h3>Template Files<a class="headerlink" href="#template-files" title="Permalink to this headline">¶</a></h3>
<p>Templates are saved in their own file, and are referenced by
<a class="reference internal" href="#tmx-object"><span class="std std-ref">objects</span></a> that are template instances.</p>
<div class="section" id="template">
<span id="tmx-template"></span><h4>&lt;template&gt;<a class="headerlink" href="#template" title="Permalink to this headline">¶</a></h4>
<p>The template root element contains the saved <a class="reference internal" href="#tmx-object"><span class="std std-ref">map object</span></a>
and a <a class="reference internal" href="#tmx-tileset"><span class="std std-ref">tileset</span></a> element that points to an external
tileset, if the object is a tile object.</p>
<p>Example of a template file:</p>
<blockquote>
<div><div class="code xml highlight-default notranslate"><div class="highlight"><pre><span></span>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;template&gt;
 &lt;tileset firstgid=&quot;1&quot; source=&quot;desert.tsx&quot;/&gt;
 &lt;object name=&quot;cactus&quot; gid=&quot;31&quot; width=&quot;81&quot; height=&quot;101&quot;/&gt;
&lt;/template&gt;
</pre></div>
</div>
</div></blockquote>
<p>Can contain at most one: <a class="reference internal" href="#tmx-tileset"><span class="std std-ref">&lt;tileset&gt;</span></a>, <a class="reference internal" href="#tmx-object"><span class="std std-ref">&lt;object&gt;</span></a></p>
<hr class="docutils" />
<div class="figure" id="id2">
<img alt="Creative Commons License" src="_images/CC-BY-SA.png" />
<p class="caption"><span class="caption-text">Creative Commons License</span></p>
</div>
<p>The <strong>TMX Map Format</strong> by <a class="reference external" href="https://www.mapeditor.org">https://www.mapeditor.org</a> is licensed under a
<a class="reference external" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported
License</a>.</p>
</div>
</div>
</div>
<span id="document-reference/tmx-changelog"></span><div class="section" id="tmx-changelog">
<h2>TMX Changelog<a class="headerlink" href="#tmx-changelog" title="Permalink to this headline">¶</a></h2>
<p>Below are described the changes/additions that were made to the
<a class="reference internal" href="index.html#document-reference/tmx-map-format"><span class="doc">TMX Map Format</span></a> for recent versions of Tiled.</p>
<div class="section" id="tiled-1-4">
<h3>Tiled 1.4<a class="headerlink" href="#tiled-1-4" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>Added the <code class="docutils literal notranslate"><span class="pre">objectalignment</span></code> attribute to the <a class="reference internal" href="index.html#tmx-tileset"><span class="std std-ref">&lt;tileset&gt;</span></a> element,
allowing the tileset to control the alignment used for tile objects.</li>
<li>Added the <code class="docutils literal notranslate"><span class="pre">tintcolor</span></code> attribute to the <a class="reference internal" href="index.html#tmx-layer"><span class="std std-ref">&lt;layer&gt;</span></a>,
<a class="reference internal" href="index.html#tmx-objectgroup"><span class="std std-ref">&lt;objectgroup&gt;</span></a>, <a class="reference internal" href="index.html#tmx-imagelayer"><span class="std std-ref">&lt;imagelayer&gt;</span></a> and <a class="reference internal" href="index.html#tmx-group"><span class="std std-ref">&lt;group&gt;</span></a> elements,
allowing for a number of graphical effects like darkening or coloring a
layer.</li>
</ul>
</div>
<div class="section" id="tiled-1-3">
<h3>Tiled 1.3<a class="headerlink" href="#tiled-1-3" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>Added an <a class="reference internal" href="index.html#tmx-editorsettings"><span class="std std-ref">&lt;editorsettings&gt;</span></a> element, which is used to store editor
specific settings that are generally not relevant when loading a map.</li>
<li>Added support for Zstandard compression for tile layer data
(<code class="docutils literal notranslate"><span class="pre">compression=&quot;zstd&quot;</span></code> on <a class="reference internal" href="index.html#tmx-data"><span class="std std-ref">&lt;data&gt;</span></a> elements).</li>
<li>Added the <code class="docutils literal notranslate"><span class="pre">compressionlevel</span></code> attribute to the <a class="reference internal" href="index.html#tmx-map"><span class="std std-ref">&lt;map&gt;</span></a> element,
which stores the compression level to use for compressed tile layer data.</li>
</ul>
</div>
<div class="section" id="tiled-1-2-1">
<h3>Tiled 1.2.1<a class="headerlink" href="#tiled-1-2-1" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>Text objects can now get their horizontal alignment saved as <code class="docutils literal notranslate"><span class="pre">justify</span></code>.
This option existed in the UI before but wasn’t saved properly.</li>
</ul>
</div>
<div class="section" id="tiled-1-2">
<h3>Tiled 1.2<a class="headerlink" href="#tiled-1-2" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>Added an <code class="docutils literal notranslate"><span class="pre">id</span></code> attribute to the <a class="reference internal" href="index.html#tmx-layer"><span class="std std-ref">&lt;layer&gt;</span></a>, <a class="reference internal" href="index.html#tmx-objectgroup"><span class="std std-ref">&lt;objectgroup&gt;</span></a>,
<a class="reference internal" href="index.html#tmx-imagelayer"><span class="std std-ref">&lt;imagelayer&gt;</span></a> and <a class="reference internal" href="index.html#tmx-group"><span class="std std-ref">&lt;group&gt;</span></a> elements, which stores a
map-unique ID of the layer.</li>
<li>Added a <code class="docutils literal notranslate"><span class="pre">nextlayerid</span></code> attribute to the <a class="reference internal" href="index.html#tmx-map"><span class="std std-ref">&lt;map&gt;</span></a> element, which
stores the next available ID for new layers. This number is stored
to prevent reuse of the same ID after layers have been removed.</li>
</ul>
</div>
<div class="section" id="tiled-1-1">
<h3>Tiled 1.1<a class="headerlink" href="#tiled-1-1" title="Permalink to this headline">¶</a></h3>
<ul>
<li><p class="first">Added a <a class="reference internal" href="index.html#tmx-map"><span class="std std-ref">map.infinite</span></a> attribute, which indicates whether
the map is considered unbounded. Tile layer data for infinite maps is
stored in chunks.</p>
</li>
<li><p class="first">A new <a class="reference internal" href="index.html#tmx-chunk"><span class="std std-ref">&lt;chunk&gt;</span></a> element was added for infinite maps which
contains the similar content as <a class="reference internal" href="index.html#tmx-data"><span class="std std-ref">&lt;data&gt;</span></a>, except it stores
the data of the area specified by its <code class="docutils literal notranslate"><span class="pre">x</span></code>, <code class="docutils literal notranslate"><span class="pre">y</span></code>, <code class="docutils literal notranslate"><span class="pre">width</span></code> and
<code class="docutils literal notranslate"><span class="pre">height</span></code> attributes.</p>
</li>
<li><p class="first"><a class="reference internal" href="index.html#document-manual/using-templates"><span class="doc">Templates</span></a> were added, a
template is an <a class="reference internal" href="index.html#tmx-template-files"><span class="std std-ref">external file</span></a> referenced
by template instance objects:</p>
<div class="code xml highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nb">object</span> <span class="nb">id</span><span class="o">=</span><span class="s2">&quot;3&quot;</span> <span class="n">template</span><span class="o">=</span><span class="s2">&quot;diamond.tx&quot;</span> <span class="n">x</span><span class="o">=</span><span class="s2">&quot;200&quot;</span> <span class="n">y</span><span class="o">=</span><span class="s2">&quot;100&quot;</span><span class="o">/&gt;</span>
</pre></div>
</div>
</li>
<li><p class="first">Tilesets can now contain <a class="reference internal" href="index.html#document-manual/using-wang-tiles"><span class="doc">Wang tiles</span></a>.
They are saved in the new <a class="reference internal" href="index.html#tmx-wangsets"><span class="std std-ref">&lt;wangsets&gt;</span></a> element.</p>
</li>
<li><p class="first">A new <a class="reference internal" href="index.html#tmx-point"><span class="std std-ref">&lt;point&gt;</span></a> child element was added to <a class="reference internal" href="index.html#tmx-object"><span class="std std-ref">&lt;object&gt;</span></a>, which
marks point objects. Point objects do not have a size or rotation.</p>
</li>
</ul>
</div>
<div class="section" id="tiled-1-0">
<h3>Tiled 1.0<a class="headerlink" href="#tiled-1-0" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>A new <a class="reference internal" href="index.html#tmx-group"><span class="std std-ref">&lt;group&gt;</span></a> element was added which is a group layer that can
have other layers as child elements. This means layers now form a hierarchy.</li>
<li>Added Text objects, identified by a new <a class="reference internal" href="index.html#tmx-text"><span class="std std-ref">&lt;text&gt;</span></a> element which is
used as a child of the <a class="reference internal" href="index.html#tmx-object"><span class="std std-ref">&lt;object&gt;</span></a> element.</li>
<li>Added a <a class="reference internal" href="index.html#tmx-tileset-tile"><span class="std std-ref">tile.type</span></a> attribute for supporting
<a class="reference internal" href="index.html#typed-tiles"><span class="std std-ref">Typed Tiles</span></a>.</li>
</ul>
</div>
<div class="section" id="tiled-0-18">
<h3>Tiled 0.18<a class="headerlink" href="#tiled-0-18" title="Permalink to this headline">¶</a></h3>
<p><em>No file format changes.</em></p>
</div>
<div class="section" id="tiled-0-17">
<h3>Tiled 0.17<a class="headerlink" href="#tiled-0-17" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>Added <code class="docutils literal notranslate"><span class="pre">color</span></code> and <code class="docutils literal notranslate"><span class="pre">file</span></code> as possible values for the
<a class="reference internal" href="index.html#tmx-property"><span class="std std-ref">property.type</span></a> attribute.</li>
<li>Added support for editing multi-line string properties, which are
written out differently.</li>
</ul>
</div>
<div class="section" id="tiled-0-16">
<h3>Tiled 0.16<a class="headerlink" href="#tiled-0-16" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>The <a class="reference internal" href="index.html#tmx-property"><span class="std std-ref">&lt;property&gt;</span></a> element gained a <code class="docutils literal notranslate"><span class="pre">type</span></code> attribute, storing the
type of the value. Currently supported types are <code class="docutils literal notranslate"><span class="pre">string</span></code> (the default),
<code class="docutils literal notranslate"><span class="pre">int</span></code>, <code class="docutils literal notranslate"><span class="pre">float</span></code> and <code class="docutils literal notranslate"><span class="pre">bool</span></code>.</li>
</ul>
</div>
<div class="section" id="tiled-0-15">
<h3>Tiled 0.15<a class="headerlink" href="#tiled-0-15" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>The <code class="docutils literal notranslate"><span class="pre">offsetx</span></code> and <code class="docutils literal notranslate"><span class="pre">offsety</span></code> attributes are now also used for
<a class="reference internal" href="index.html#tmx-imagelayer"><span class="std std-ref">&lt;imagelayer&gt;</span></a> elements, replacing the <code class="docutils literal notranslate"><span class="pre">x</span></code> and <code class="docutils literal notranslate"><span class="pre">y</span></code> attributes
previously used. This change was made for consistency with the other layer
types.</li>
<li>The tiles in an image collection tileset are no longer guaranteed to
be consecutive, because removing tiles from the collection will no
longer change the IDs of other tiles.</li>
<li>The pure XML and Gzip-compressed tile layer data formats were
deprecated, since they didn’t have any advantage over other formats.
Remaining formats are CSV, base64 and Zlib-compressed layer data.</li>
<li>Added <code class="docutils literal notranslate"><span class="pre">columns</span></code> attribute to the
<a class="reference internal" href="index.html#tmx-tileset"><span class="std std-ref">&lt;tileset&gt;</span></a> element, which specifies the number of tile columns in
the tileset. For image collection tilesets it is editable and is used when
displaying the tileset.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">backgroundcolor</span></code> attribute of the
<a class="reference internal" href="index.html#tmx-map"><span class="std std-ref">&lt;map&gt;</span></a> element will now take the format <code class="docutils literal notranslate"><span class="pre">#AARRGGBB</span></code> when its alpha
value differs from 255. Previously the alpha value was silently discarded.</li>
</ul>
</div>
<div class="section" id="tiled-0-14">
<h3>Tiled 0.14<a class="headerlink" href="#tiled-0-14" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>Added optional <code class="docutils literal notranslate"><span class="pre">offsetx</span></code> and <code class="docutils literal notranslate"><span class="pre">offsety</span></code> attributes to the
<code class="docutils literal notranslate"><span class="pre">layer</span></code> and <code class="docutils literal notranslate"><span class="pre">objectgroup</span></code> elements. These specify an offset in
pixels that is to be applied when rendering the layer. The default
values are 0.</li>
</ul>
</div>
<div class="section" id="tiled-0-13">
<h3>Tiled 0.13<a class="headerlink" href="#tiled-0-13" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>Added an optional <code class="docutils literal notranslate"><span class="pre">tilecount</span></code> attribute to the <code class="docutils literal notranslate"><span class="pre">tileset</span></code> element,
which is written by Tiled to help parsers determine the amount of
memory to allocate for tile data.</li>
</ul>
</div>
<div class="section" id="tiled-0-12">
<h3>Tiled 0.12<a class="headerlink" href="#tiled-0-12" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>Previously tile objects never had <code class="docutils literal notranslate"><span class="pre">width</span></code> and <code class="docutils literal notranslate"><span class="pre">height</span></code>
properties, though the format technically allowed this. Now these
properties are used to store the size the image should be rendered
at. The default values for these attributes are the dimensions of the
tile image.</li>
</ul>
</div>
<div class="section" id="tiled-0-11">
<h3>Tiled 0.11<a class="headerlink" href="#tiled-0-11" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>Added <code class="docutils literal notranslate"><span class="pre">hexagonal</span></code> to the supported values for the <code class="docutils literal notranslate"><span class="pre">orientation</span></code>
attribute on the <code class="docutils literal notranslate"><span class="pre">map</span></code> element. This also adds <code class="docutils literal notranslate"><span class="pre">staggerindex</span></code>
(<code class="docutils literal notranslate"><span class="pre">even</span></code> or <code class="docutils literal notranslate"><span class="pre">odd</span></code>) and <code class="docutils literal notranslate"><span class="pre">staggeraxis</span></code> (<code class="docutils literal notranslate"><span class="pre">x</span></code> or <code class="docutils literal notranslate"><span class="pre">y</span></code>) and
<code class="docutils literal notranslate"><span class="pre">hexsidelength</span></code> (integer value) attributes to the <code class="docutils literal notranslate"><span class="pre">map</span></code> element,
in order to support the many variations of staggered hexagonal. The
new <code class="docutils literal notranslate"><span class="pre">staggerindex</span></code> and <code class="docutils literal notranslate"><span class="pre">staggeraxis</span></code> attributes are also
supported when using the <code class="docutils literal notranslate"><span class="pre">staggered</span></code> map orientation.</li>
<li>Added an <code class="docutils literal notranslate"><span class="pre">id</span></code> attribute to the <code class="docutils literal notranslate"><span class="pre">object</span></code> element, which stores a
map-unique ID of the object.</li>
<li>Added a <code class="docutils literal notranslate"><span class="pre">nextobjectid</span></code> attribute to the <code class="docutils literal notranslate"><span class="pre">map</span></code> element, which
stores the next available ID for new objects. This number is stored
to prevent reuse of the same ID after objects have been removed.</li>
</ul>
</div>
<div class="section" id="tiled-0-10">
<h3>Tiled 0.10<a class="headerlink" href="#tiled-0-10" title="Permalink to this headline">¶</a></h3>
<ul>
<li><p class="first">Tile objects can now be horizontally or vertically flipped. This is
stored in the <code class="docutils literal notranslate"><span class="pre">gid</span></code> attribute using the same mechanism as for
regular tiles. The image is expected to be flipped without affecting
its position, same way as flipped tiles.</p>
</li>
<li><p class="first">Objects can be rotated freely. The rotation is stored in degrees as a
<code class="docutils literal notranslate"><span class="pre">rotation</span></code> attribute, with positive rotation going clockwise.</p>
</li>
<li><p class="first">The render order of the tiles on tile layers can be configured in a
number of ways through a new <code class="docutils literal notranslate"><span class="pre">renderorder</span></code> property on the <code class="docutils literal notranslate"><span class="pre">map</span></code>
element. Valid values are <code class="docutils literal notranslate"><span class="pre">right-down</span></code> (the default), <code class="docutils literal notranslate"><span class="pre">right-up</span></code>,
<code class="docutils literal notranslate"><span class="pre">left-down</span></code> and <code class="docutils literal notranslate"><span class="pre">left-up</span></code>. In all cases, the map is drawn
row-by-row. This is only supported for orthogonal maps at the moment.</p>
</li>
<li><p class="first">The render order of objects on object layers can be configured to be
either sorted by their y-coordinate (previous behavior and still the
default) or simply the order of appearance in the map file. The
latter enables manual control over the drawing order with actions
that “Raise” and “Lower” selected objects. It is controlled by the
<code class="docutils literal notranslate"><span class="pre">draworder</span></code> property on the <code class="docutils literal notranslate"><span class="pre">objectgroup</span></code> element, which can be
either <code class="docutils literal notranslate"><span class="pre">topdown</span></code> (default) or <code class="docutils literal notranslate"><span class="pre">index</span></code>.</p>
</li>
<li><p class="first">Tiles can have an <code class="docutils literal notranslate"><span class="pre">objectgroup</span></code> child element, which can contain
objects that define the collision shape to use for that tile. This
information can be edited in the new Tile Collision Editor.</p>
</li>
<li><p class="first">Tiles can have a single looping animation associated with them using
an <code class="docutils literal notranslate"><span class="pre">animation</span></code> child element. Each frame of the animation refers to
a local tile ID from this tileset and defines the frame duration in
milliseconds. Example:</p>
<div class="code xml highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="n">tileset</span> <span class="o">...&gt;</span>
<span class="o">...</span>
<span class="o">&lt;</span><span class="n">tile</span> <span class="nb">id</span><span class="o">=</span><span class="s2">&quot;[n]&quot;</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">animation</span><span class="o">&gt;</span>
        <span class="o">&lt;</span><span class="n">frame</span> <span class="n">tileid</span><span class="o">=</span><span class="s2">&quot;0&quot;</span> <span class="n">duration</span><span class="o">=</span><span class="s2">&quot;100&quot;</span><span class="o">/&gt;</span>
        <span class="o">&lt;</span><span class="n">frame</span> <span class="n">tileid</span><span class="o">=</span><span class="s2">&quot;1&quot;</span> <span class="n">duration</span><span class="o">=</span><span class="s2">&quot;100&quot;</span><span class="o">/&gt;</span>
        <span class="o">&lt;</span><span class="n">frame</span> <span class="n">tileid</span><span class="o">=</span><span class="s2">&quot;2&quot;</span> <span class="n">duration</span><span class="o">=</span><span class="s2">&quot;100&quot;</span><span class="o">/&gt;</span>
    <span class="o">&lt;/</span><span class="n">animation</span><span class="o">&gt;</span>
<span class="o">&lt;/</span><span class="n">tile</span><span class="o">&gt;</span>
<span class="o">&lt;/</span><span class="n">tileset</span><span class="o">&gt;</span>
</pre></div>
</div>
</li>
</ul>
</div>
<div class="section" id="tiled-0-9">
<h3>Tiled 0.9<a class="headerlink" href="#tiled-0-9" title="Permalink to this headline">¶</a></h3>
<ul>
<li><p class="first">Per-object visibility flag is saved (defaults to 1):</p>
<div class="code xml highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nb">object</span> <span class="n">visible</span><span class="o">=</span><span class="s2">&quot;0|1&quot;</span><span class="o">&gt;</span>
</pre></div>
</div>
</li>
<li><p class="first">Terrain information was added to tileset definitions (this is
generally not very relevant for games):</p>
<div class="code xml highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="n">tileset</span> <span class="o">...&gt;</span>
<span class="o">...</span>
<span class="o">&lt;</span><span class="n">terraintypes</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="n">terrain</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;Name&quot;</span> <span class="n">tile</span><span class="o">=</span><span class="s2">&quot;local_id&quot;</span><span class="o">/&gt;</span>
<span class="o">&lt;/</span><span class="n">terraintypes</span><span class="o">&gt;</span>
<span class="o">&lt;</span><span class="n">tile</span> <span class="nb">id</span><span class="o">=</span><span class="s2">&quot;local_id&quot;</span> <span class="n">terrain</span><span class="o">=</span><span class="s2">&quot;[n],[n],[n],[n]&quot;</span> <span class="n">probability</span><span class="o">=</span><span class="s2">&quot;percentage&quot;</span><span class="o">/&gt;</span>
<span class="o">...</span>
<span class="o">&lt;/</span><span class="n">tileset</span><span class="o">&gt;</span>
</pre></div>
</div>
</li>
<li><p class="first">There is preliminary support for a “staggered” (isometric) projection
(new value for the <code class="docutils literal notranslate"><span class="pre">orientation</span></code> attribute of the <code class="docutils literal notranslate"><span class="pre">map</span></code> element).</p>
</li>
<li><p class="first">A basic image layer type was added:</p>
<div class="code xml highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="n">imagelayer</span> <span class="o">...&gt;</span>
<span class="o">&lt;</span><span class="n">image</span> <span class="n">source</span><span class="o">=</span><span class="s2">&quot;...&quot;</span><span class="o">/&gt;</span>
<span class="o">&lt;/</span><span class="n">imagelayer</span><span class="o">&gt;</span>
</pre></div>
</div>
</li>
<li><p class="first">Added ellipse object shape. Same parameters as rectangular objects,
but marked as ellipse with a child element:</p>
<div class="code xml highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nb">object</span> <span class="o">...&gt;</span>
<span class="o">&lt;</span><span class="n">ellipse</span><span class="o">/&gt;</span>
<span class="o">&lt;/</span><span class="nb">object</span><span class="o">&gt;</span>
</pre></div>
</div>
</li>
<li><p class="first">Added map property for specifying the background color:</p>
<div class="code xml highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="nb">map</span> <span class="o">...</span> <span class="n">backgroundcolor</span><span class="o">=</span><span class="s2">&quot;#RRGGBB&quot;</span><span class="o">&gt;</span>
</pre></div>
</div>
</li>
<li><p class="first">Added initial (non-GUI) support for individual and/or embedded tile
images (since there is no way to set this up in Tiled Qt but only in
Tiled Java or with
<a class="reference external" href="https://github.com/encukou/pytmxlib">pytmxlib</a>, this is not very
important to support at the moment):</p>
<div class="code xml highlight-default notranslate"><div class="highlight"><pre><span></span>&lt;tileset ...&gt;
&lt;tile id=&quot;[n]&quot;&gt;
    &lt;!-- an embedded image --&gt;
    &lt;image format=&quot;png&quot;&gt;
        &lt;data encoding=&quot;base64&quot;&gt;
            ...
        &lt;/data&gt;
    &lt;/image&gt;
&lt;/tile&gt;
&lt;tile id=&quot;[n]&quot;&gt;
    &lt;!-- an individually referenced image for a single tile --&gt;
    &lt;image source=&quot;file.png&quot;/&gt;
&lt;/tile&gt;
...
&lt;/tileset&gt;
</pre></div>
</div>
</li>
</ul>
</div>
<div class="section" id="tiled-0-8">
<h3>Tiled 0.8<a class="headerlink" href="#tiled-0-8" title="Permalink to this headline">¶</a></h3>
<ul>
<li><p class="first">Tilesets can now have custom properties (using the <code class="docutils literal notranslate"><span class="pre">properties</span></code>
child element, just like everything else).</p>
</li>
<li><p class="first">Tilesets now support defining a drawing offset in pixels, which is to
be used when drawing any tiles from that tileset. Example:</p>
<div class="code xml highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="n">tileset</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;perspective_walls&quot;</span> <span class="n">tilewidth</span><span class="o">=</span><span class="s2">&quot;64&quot;</span> <span class="n">tileheight</span><span class="o">=</span><span class="s2">&quot;64&quot;</span><span class="o">&gt;</span>
<span class="o">&lt;</span><span class="n">tileoffset</span> <span class="n">x</span><span class="o">=</span><span class="s2">&quot;-32&quot;</span> <span class="n">y</span><span class="o">=</span><span class="s2">&quot;0&quot;</span><span class="o">/&gt;</span>
<span class="o">...</span>
<span class="o">&lt;/</span><span class="n">tileset</span><span class="o">&gt;</span>
</pre></div>
</div>
</li>
<li><p class="first">Support for tile rotation in 90-degree increments was added by using
the third most significant bit in the global tile id. This new bit
means “anti-diagonal flip”, which swaps the x and y axis when
rendering a tile.</p>
</li>
</ul>
</div>
</div>
<span id="document-reference/json-map-format"></span><div class="section" id="json-map-format">
<h2>JSON Map Format<a class="headerlink" href="#json-map-format" title="Permalink to this headline">¶</a></h2>
<p>Tiled can export maps as JSON files. To do so, simply select “File &gt;
Export As” and select the JSON file type. You can export json from the
command line with the <code class="docutils literal notranslate"><span class="pre">--export-map</span></code> option.</p>
<p>The fields found in the JSON format differ slightly from those in the
<a class="reference internal" href="index.html#document-reference/tmx-map-format"><span class="doc">TMX Map Format</span></a>, but the meanings should remain the same.</p>
<p>The following fields can be found in a Tiled JSON file:</p>
<div class="section" id="map">
<span id="json-map"></span><h3>Map<a class="headerlink" href="#map" title="Permalink to this headline">¶</a></h3>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>backgroundcolor</td>
<td>string</td>
<td>Hex-formatted color (#RRGGBB or #AARRGGBB) (optional)</td>
</tr>
<tr class="row-odd"><td>compressionlevel</td>
<td>int</td>
<td>The compression level to use for tile layer data (defaults to -1, which means to use the algorithm default)</td>
</tr>
<tr class="row-even"><td>height</td>
<td>int</td>
<td>Number of tile rows</td>
</tr>
<tr class="row-odd"><td>hexsidelength</td>
<td>int</td>
<td>Length of the side of a hex tile in pixels (hexagonal maps only)</td>
</tr>
<tr class="row-even"><td>infinite</td>
<td>bool</td>
<td>Whether the map has infinite dimensions</td>
</tr>
<tr class="row-odd"><td>layers</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-layer"><span class="std std-ref">Layers</span></a></td>
</tr>
<tr class="row-even"><td>nextlayerid</td>
<td>int</td>
<td>Auto-increments for each layer</td>
</tr>
<tr class="row-odd"><td>nextobjectid</td>
<td>int</td>
<td>Auto-increments for each placed object</td>
</tr>
<tr class="row-even"><td>orientation</td>
<td>string</td>
<td><code class="docutils literal notranslate"><span class="pre">orthogonal</span></code>, <code class="docutils literal notranslate"><span class="pre">isometric</span></code>, <code class="docutils literal notranslate"><span class="pre">staggered</span></code> or <code class="docutils literal notranslate"><span class="pre">hexagonal</span></code></td>
</tr>
<tr class="row-odd"><td>properties</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-property"><span class="std std-ref">Properties</span></a></td>
</tr>
<tr class="row-even"><td>renderorder</td>
<td>string</td>
<td><code class="docutils literal notranslate"><span class="pre">right-down</span></code> (the default), <code class="docutils literal notranslate"><span class="pre">right-up</span></code>, <code class="docutils literal notranslate"><span class="pre">left-down</span></code> or <code class="docutils literal notranslate"><span class="pre">left-up</span></code> (currently only supported for orthogonal maps)</td>
</tr>
<tr class="row-odd"><td>staggeraxis</td>
<td>string</td>
<td><code class="docutils literal notranslate"><span class="pre">x</span></code> or <code class="docutils literal notranslate"><span class="pre">y</span></code> (staggered / hexagonal maps only)</td>
</tr>
<tr class="row-even"><td>staggerindex</td>
<td>string</td>
<td><code class="docutils literal notranslate"><span class="pre">odd</span></code> or <code class="docutils literal notranslate"><span class="pre">even</span></code> (staggered / hexagonal maps only)</td>
</tr>
<tr class="row-odd"><td>tiledversion</td>
<td>string</td>
<td>The Tiled version used to save the file</td>
</tr>
<tr class="row-even"><td>tileheight</td>
<td>int</td>
<td>Map grid height</td>
</tr>
<tr class="row-odd"><td>tilesets</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-tileset"><span class="std std-ref">Tilesets</span></a></td>
</tr>
<tr class="row-even"><td>tilewidth</td>
<td>int</td>
<td>Map grid width</td>
</tr>
<tr class="row-odd"><td>type</td>
<td>string</td>
<td><code class="docutils literal notranslate"><span class="pre">map</span></code> (since 1.0)</td>
</tr>
<tr class="row-even"><td>version</td>
<td>number</td>
<td>The JSON format version</td>
</tr>
<tr class="row-odd"><td>width</td>
<td>int</td>
<td>Number of tile columns</td>
</tr>
</tbody>
</table>
<div class="section" id="map-example">
<h4>Map Example<a class="headerlink" href="#map-example" title="Permalink to this headline">¶</a></h4>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;backgroundcolor&quot;</span><span class="p">:</span><span class="s2">&quot;#656667&quot;</span><span class="p">,</span>
  <span class="s2">&quot;height&quot;</span><span class="p">:</span><span class="mi">4</span><span class="p">,</span>
  <span class="s2">&quot;layers&quot;</span><span class="p">:[</span> <span class="p">],</span>
  <span class="s2">&quot;nextobjectid&quot;</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span>
  <span class="s2">&quot;orientation&quot;</span><span class="p">:</span><span class="s2">&quot;orthogonal&quot;</span><span class="p">,</span>
  <span class="s2">&quot;properties&quot;</span><span class="p">:[</span>
    <span class="p">{</span>
      <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;mapProperty1&quot;</span><span class="p">,</span>
      <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;string&quot;</span><span class="p">,</span>
      <span class="s2">&quot;value&quot;</span><span class="p">:</span><span class="s2">&quot;one&quot;</span>
    <span class="p">},</span>
    <span class="p">{</span>
      <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;mapProperty2&quot;</span><span class="p">,</span>
      <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;string&quot;</span><span class="p">,</span>
      <span class="s2">&quot;value&quot;</span><span class="p">:</span><span class="s2">&quot;two&quot;</span>
    <span class="p">}],</span>
  <span class="s2">&quot;renderorder&quot;</span><span class="p">:</span><span class="s2">&quot;right-down&quot;</span><span class="p">,</span>
  <span class="s2">&quot;tileheight&quot;</span><span class="p">:</span><span class="mi">32</span><span class="p">,</span>
  <span class="s2">&quot;tilesets&quot;</span><span class="p">:[</span> <span class="p">],</span>
  <span class="s2">&quot;tilewidth&quot;</span><span class="p">:</span><span class="mi">32</span><span class="p">,</span>
  <span class="s2">&quot;version&quot;</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span>
  <span class="s2">&quot;tiledversion&quot;</span><span class="p">:</span><span class="s2">&quot;1.0.3&quot;</span><span class="p">,</span>
  <span class="s2">&quot;width&quot;</span><span class="p">:</span><span class="mi">4</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="layer">
<span id="json-layer"></span><h3>Layer<a class="headerlink" href="#layer" title="Permalink to this headline">¶</a></h3>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>chunks</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-chunk"><span class="std std-ref">chunks</span></a> (optional). <code class="docutils literal notranslate"><span class="pre">tilelayer</span></code> only.</td>
</tr>
<tr class="row-odd"><td>compression</td>
<td>string</td>
<td><code class="docutils literal notranslate"><span class="pre">zlib</span></code>, <code class="docutils literal notranslate"><span class="pre">gzip</span></code>, <code class="docutils literal notranslate"><span class="pre">zstd</span></code> (since Tiled 1.3) or empty (default). <code class="docutils literal notranslate"><span class="pre">tilelayer</span></code> only.</td>
</tr>
<tr class="row-even"><td>data</td>
<td>array or string</td>
<td>Array of <code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">int</span></code> (GIDs) or base64-encoded data. <code class="docutils literal notranslate"><span class="pre">tilelayer</span></code> only.</td>
</tr>
<tr class="row-odd"><td>draworder</td>
<td>string</td>
<td><code class="docutils literal notranslate"><span class="pre">topdown</span></code> (default) or <code class="docutils literal notranslate"><span class="pre">index</span></code>. <code class="docutils literal notranslate"><span class="pre">objectgroup</span></code> only.</td>
</tr>
<tr class="row-even"><td>encoding</td>
<td>string</td>
<td><code class="docutils literal notranslate"><span class="pre">csv</span></code> (default) or <code class="docutils literal notranslate"><span class="pre">base64</span></code>. <code class="docutils literal notranslate"><span class="pre">tilelayer</span></code> only.</td>
</tr>
<tr class="row-odd"><td>height</td>
<td>int</td>
<td>Row count. Same as map height for fixed-size maps.</td>
</tr>
<tr class="row-even"><td>id</td>
<td>int</td>
<td>Incremental ID - unique across all layers</td>
</tr>
<tr class="row-odd"><td>image</td>
<td>string</td>
<td>Image used by this layer. <code class="docutils literal notranslate"><span class="pre">imagelayer</span></code> only.</td>
</tr>
<tr class="row-even"><td>layers</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-layer"><span class="std std-ref">layers</span></a>. <code class="docutils literal notranslate"><span class="pre">group</span></code> only.</td>
</tr>
<tr class="row-odd"><td>name</td>
<td>string</td>
<td>Name assigned to this layer</td>
</tr>
<tr class="row-even"><td>objects</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-object"><span class="std std-ref">objects</span></a>. <code class="docutils literal notranslate"><span class="pre">objectgroup</span></code> only.</td>
</tr>
<tr class="row-odd"><td>offsetx</td>
<td>double</td>
<td>Horizontal layer offset in pixels (default: 0)</td>
</tr>
<tr class="row-even"><td>offsety</td>
<td>double</td>
<td>Vertical layer offset in pixels (default: 0)</td>
</tr>
<tr class="row-odd"><td>opacity</td>
<td>double</td>
<td>Value between 0 and 1</td>
</tr>
<tr class="row-even"><td>properties</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-property"><span class="std std-ref">Properties</span></a></td>
</tr>
<tr class="row-odd"><td>startx</td>
<td>int</td>
<td>X coordinate where layer content starts (for infinite maps)</td>
</tr>
<tr class="row-even"><td>starty</td>
<td>int</td>
<td>Y coordinate where layer content starts (for infinite maps)</td>
</tr>
<tr class="row-odd"><td>tintcolor</td>
<td>string</td>
<td>Hex-formatted color (#RRGGBB or #AARRGGBB) that is multiplied with any graphics drawn by this layer or any child layers (optional).</td>
</tr>
<tr class="row-even"><td>transparentcolor</td>
<td>string</td>
<td>Hex-formatted color (#RRGGBB) (optional). <code class="docutils literal notranslate"><span class="pre">imagelayer</span></code> only.</td>
</tr>
<tr class="row-odd"><td>type</td>
<td>string</td>
<td><code class="docutils literal notranslate"><span class="pre">tilelayer</span></code>, <code class="docutils literal notranslate"><span class="pre">objectgroup</span></code>, <code class="docutils literal notranslate"><span class="pre">imagelayer</span></code> or <code class="docutils literal notranslate"><span class="pre">group</span></code></td>
</tr>
<tr class="row-even"><td>visible</td>
<td>bool</td>
<td>Whether layer is shown or hidden in editor</td>
</tr>
<tr class="row-odd"><td>width</td>
<td>int</td>
<td>Column count. Same as map width for fixed-size maps.</td>
</tr>
<tr class="row-even"><td>x</td>
<td>int</td>
<td>Horizontal layer offset in tiles. Always 0.</td>
</tr>
<tr class="row-odd"><td>y</td>
<td>int</td>
<td>Vertical layer offset in tiles. Always 0.</td>
</tr>
</tbody>
</table>
<div class="section" id="tile-layer-example">
<h4>Tile Layer Example<a class="headerlink" href="#tile-layer-example" title="Permalink to this headline">¶</a></h4>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;data&quot;</span><span class="p">:[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span>
  <span class="s2">&quot;height&quot;</span><span class="p">:</span><span class="mi">4</span><span class="p">,</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;ground&quot;</span><span class="p">,</span>
  <span class="s2">&quot;opacity&quot;</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span>
  <span class="s2">&quot;properties&quot;</span><span class="p">:[</span>
    <span class="p">{</span>
      <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;tileLayerProp&quot;</span><span class="p">,</span>
      <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;int&quot;</span><span class="p">,</span>
      <span class="s2">&quot;value&quot;</span><span class="p">:</span><span class="mi">1</span>
    <span class="p">}],</span>
  <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;tilelayer&quot;</span><span class="p">,</span>
  <span class="s2">&quot;visible&quot;</span><span class="p">:</span><span class="n">true</span><span class="p">,</span>
  <span class="s2">&quot;width&quot;</span><span class="p">:</span><span class="mi">4</span><span class="p">,</span>
  <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">0</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="object-layer-example">
<h4>Object Layer Example<a class="headerlink" href="#object-layer-example" title="Permalink to this headline">¶</a></h4>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;draworder&quot;</span><span class="p">:</span><span class="s2">&quot;topdown&quot;</span><span class="p">,</span>
  <span class="s2">&quot;height&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;people&quot;</span><span class="p">,</span>
  <span class="s2">&quot;objects&quot;</span><span class="p">:[</span> <span class="p">],</span>
  <span class="s2">&quot;opacity&quot;</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span>
  <span class="s2">&quot;properties&quot;</span><span class="p">:[</span>
    <span class="p">{</span>
      <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;layerProp1&quot;</span><span class="p">,</span>
      <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;string&quot;</span><span class="p">,</span>
      <span class="s2">&quot;value&quot;</span><span class="p">:</span><span class="s2">&quot;someStringValue&quot;</span>
    <span class="p">}],</span>
  <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;objectgroup&quot;</span><span class="p">,</span>
  <span class="s2">&quot;visible&quot;</span><span class="p">:</span><span class="n">true</span><span class="p">,</span>
  <span class="s2">&quot;width&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">0</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="chunk">
<span id="json-chunk"></span><h3>Chunk<a class="headerlink" href="#chunk" title="Permalink to this headline">¶</a></h3>
<p>Chunks are used to store the tile layer data for
<a class="reference internal" href="index.html#document-manual/using-infinite-maps"><span class="doc">infinite maps</span></a>.</p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>data</td>
<td>array or string</td>
<td>Array of <code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">int</span></code> (GIDs) or base64-encoded data</td>
</tr>
<tr class="row-odd"><td>height</td>
<td>int</td>
<td>Height in tiles</td>
</tr>
<tr class="row-even"><td>width</td>
<td>int</td>
<td>Width in tiles</td>
</tr>
<tr class="row-odd"><td>x</td>
<td>int</td>
<td>X coordinate in tiles</td>
</tr>
<tr class="row-even"><td>y</td>
<td>int</td>
<td>Y coordinate in tiles</td>
</tr>
</tbody>
</table>
<div class="section" id="chunk-example">
<h4>Chunk Example<a class="headerlink" href="#chunk-example" title="Permalink to this headline">¶</a></h4>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;data&quot;</span><span class="p">:[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span>
  <span class="s2">&quot;height&quot;</span><span class="p">:</span><span class="mi">16</span><span class="p">,</span>
  <span class="s2">&quot;width&quot;</span><span class="p">:</span><span class="mi">16</span><span class="p">,</span>
  <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="o">-</span><span class="mi">16</span><span class="p">,</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="object">
<span id="json-object"></span><h3>Object<a class="headerlink" href="#object" title="Permalink to this headline">¶</a></h3>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>ellipse</td>
<td>bool</td>
<td>Used to mark an object as an ellipse</td>
</tr>
<tr class="row-odd"><td>gid</td>
<td>int</td>
<td>Global tile ID, only if object represents a tile</td>
</tr>
<tr class="row-even"><td>height</td>
<td>double</td>
<td>Height in pixels.</td>
</tr>
<tr class="row-odd"><td>id</td>
<td>int</td>
<td>Incremental ID, unique across all objects</td>
</tr>
<tr class="row-even"><td>name</td>
<td>string</td>
<td>String assigned to name field in editor</td>
</tr>
<tr class="row-odd"><td>point</td>
<td>bool</td>
<td>Used to mark an object as a point</td>
</tr>
<tr class="row-even"><td>polygon</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-point"><span class="std std-ref">Points</span></a>, in case the object is a polygon</td>
</tr>
<tr class="row-odd"><td>polyline</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-point"><span class="std std-ref">Points</span></a>, in case the object is a polyline</td>
</tr>
<tr class="row-even"><td>properties</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-property"><span class="std std-ref">Properties</span></a></td>
</tr>
<tr class="row-odd"><td>rotation</td>
<td>double</td>
<td>Angle in degrees clockwise</td>
</tr>
<tr class="row-even"><td>template</td>
<td>string</td>
<td>Reference to a template file, in case object is a <a class="reference internal" href="index.html#document-manual/using-templates"><span class="doc">template instance</span></a></td>
</tr>
<tr class="row-odd"><td>text</td>
<td><a class="reference internal" href="#json-object-text"><span class="std std-ref">Text</span></a></td>
<td>Only used for text objects</td>
</tr>
<tr class="row-even"><td>type</td>
<td>string</td>
<td>String assigned to type field in editor</td>
</tr>
<tr class="row-odd"><td>visible</td>
<td>bool</td>
<td>Whether object is shown in editor.</td>
</tr>
<tr class="row-even"><td>width</td>
<td>double</td>
<td>Width in pixels.</td>
</tr>
<tr class="row-odd"><td>x</td>
<td>double</td>
<td>X coordinate in pixels</td>
</tr>
<tr class="row-even"><td>y</td>
<td>double</td>
<td>Y coordinate in pixels</td>
</tr>
</tbody>
</table>
<div class="section" id="object-example">
<h4>Object Example<a class="headerlink" href="#object-example" title="Permalink to this headline">¶</a></h4>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;gid&quot;</span><span class="p">:</span><span class="mi">5</span><span class="p">,</span>
  <span class="s2">&quot;height&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;villager&quot;</span><span class="p">,</span>
  <span class="s2">&quot;properties&quot;</span><span class="p">:[</span>
    <span class="p">{</span>
      <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;hp&quot;</span><span class="p">,</span>
      <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;int&quot;</span><span class="p">,</span>
      <span class="s2">&quot;value&quot;</span><span class="p">:</span><span class="mi">12</span>
    <span class="p">}],</span>
  <span class="s2">&quot;rotation&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;npc&quot;</span><span class="p">,</span>
  <span class="s2">&quot;visible&quot;</span><span class="p">:</span><span class="n">true</span><span class="p">,</span>
  <span class="s2">&quot;width&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">32</span><span class="p">,</span>
  <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">32</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="ellipse-example">
<h4>Ellipse Example<a class="headerlink" href="#ellipse-example" title="Permalink to this headline">¶</a></h4>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;ellipse&quot;</span><span class="p">:</span><span class="n">true</span><span class="p">,</span>
  <span class="s2">&quot;height&quot;</span><span class="p">:</span><span class="mi">152</span><span class="p">,</span>
  <span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="mi">13</span><span class="p">,</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
  <span class="s2">&quot;rotation&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
  <span class="s2">&quot;visible&quot;</span><span class="p">:</span><span class="n">true</span><span class="p">,</span>
  <span class="s2">&quot;width&quot;</span><span class="p">:</span><span class="mi">248</span><span class="p">,</span>
  <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">560</span><span class="p">,</span>
  <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">808</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="rectangle-example">
<h4>Rectangle Example<a class="headerlink" href="#rectangle-example" title="Permalink to this headline">¶</a></h4>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;height&quot;</span><span class="p">:</span><span class="mi">184</span><span class="p">,</span>
  <span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="mi">14</span><span class="p">,</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
  <span class="s2">&quot;rotation&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
  <span class="s2">&quot;visible&quot;</span><span class="p">:</span><span class="n">true</span><span class="p">,</span>
  <span class="s2">&quot;width&quot;</span><span class="p">:</span><span class="mi">368</span><span class="p">,</span>
  <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">576</span><span class="p">,</span>
  <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">584</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="point-example">
<h4>Point Example<a class="headerlink" href="#point-example" title="Permalink to this headline">¶</a></h4>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;point&quot;</span><span class="p">:</span><span class="n">true</span><span class="p">,</span>
  <span class="s2">&quot;height&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="mi">20</span><span class="p">,</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
  <span class="s2">&quot;rotation&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
  <span class="s2">&quot;visible&quot;</span><span class="p">:</span><span class="n">true</span><span class="p">,</span>
  <span class="s2">&quot;width&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">220</span><span class="p">,</span>
  <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">350</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="polygon-example">
<h4>Polygon Example<a class="headerlink" href="#polygon-example" title="Permalink to this headline">¶</a></h4>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;height&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="mi">15</span><span class="p">,</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
  <span class="s2">&quot;polygon&quot;</span><span class="p">:[</span>
  <span class="p">{</span>
    <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
    <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">0</span>
  <span class="p">},</span>
  <span class="p">{</span>
    <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">152</span><span class="p">,</span>
    <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">88</span>
  <span class="p">},</span>
  <span class="p">{</span>
    <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">136</span><span class="p">,</span>
    <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="o">-</span><span class="mi">128</span>
  <span class="p">},</span>
  <span class="p">{</span>
    <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">80</span><span class="p">,</span>
    <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="o">-</span><span class="mi">280</span>
  <span class="p">},</span>
  <span class="p">{</span>
    <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">16</span><span class="p">,</span>
    <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="o">-</span><span class="mi">288</span>
  <span class="p">}],</span>
  <span class="s2">&quot;rotation&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
  <span class="s2">&quot;visible&quot;</span><span class="p">:</span><span class="n">true</span><span class="p">,</span>
  <span class="s2">&quot;width&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="o">-</span><span class="mi">176</span><span class="p">,</span>
  <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">432</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="polyline-example">
<h4>Polyline Example<a class="headerlink" href="#polyline-example" title="Permalink to this headline">¶</a></h4>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;height&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="mi">16</span><span class="p">,</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
  <span class="s2">&quot;polyline&quot;</span><span class="p">:[</span>
  <span class="p">{</span>
    <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
    <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">0</span>
  <span class="p">},</span>
  <span class="p">{</span>
    <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">248</span><span class="p">,</span>
    <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="o">-</span><span class="mi">32</span>
  <span class="p">},</span>
  <span class="p">{</span>
    <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">376</span><span class="p">,</span>
    <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">72</span>
  <span class="p">},</span>
  <span class="p">{</span>
    <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">544</span><span class="p">,</span>
    <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">288</span>
  <span class="p">},</span>
  <span class="p">{</span>
    <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">656</span><span class="p">,</span>
    <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">120</span>
  <span class="p">},</span>
  <span class="p">{</span>
    <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">512</span><span class="p">,</span>
    <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">0</span>
  <span class="p">}],</span>
  <span class="s2">&quot;rotation&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
  <span class="s2">&quot;visible&quot;</span><span class="p">:</span><span class="n">true</span><span class="p">,</span>
  <span class="s2">&quot;width&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">240</span><span class="p">,</span>
  <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">88</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="text-example">
<h4>Text Example<a class="headerlink" href="#text-example" title="Permalink to this headline">¶</a></h4>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;height&quot;</span><span class="p">:</span><span class="mi">19</span><span class="p">,</span>
  <span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="mi">15</span><span class="p">,</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
  <span class="s2">&quot;text&quot;</span><span class="p">:</span>
  <span class="p">{</span>
    <span class="s2">&quot;text&quot;</span><span class="p">:</span><span class="s2">&quot;Hello World&quot;</span><span class="p">,</span>
    <span class="s2">&quot;wrap&quot;</span><span class="p">:</span><span class="n">true</span>
  <span class="p">},</span>
  <span class="s2">&quot;rotation&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
  <span class="s2">&quot;visible&quot;</span><span class="p">:</span><span class="n">true</span><span class="p">,</span>
  <span class="s2">&quot;width&quot;</span><span class="p">:</span><span class="mi">248</span><span class="p">,</span>
  <span class="s2">&quot;x&quot;</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span>
  <span class="s2">&quot;y&quot;</span><span class="p">:</span><span class="mi">136</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="text">
<span id="json-object-text"></span><h3>Text<a class="headerlink" href="#text" title="Permalink to this headline">¶</a></h3>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>bold</td>
<td>bool</td>
<td>Whether to use a bold font (default: <code class="docutils literal notranslate"><span class="pre">false</span></code>)</td>
</tr>
<tr class="row-odd"><td>color</td>
<td>string</td>
<td>Hex-formatted color (#RRGGBB or #AARRGGBB) (default: <code class="docutils literal notranslate"><span class="pre">#000000</span></code>)</td>
</tr>
<tr class="row-even"><td>fontfamily</td>
<td>string</td>
<td>Font family (default: <code class="docutils literal notranslate"><span class="pre">sans-serif</span></code>)</td>
</tr>
<tr class="row-odd"><td>halign</td>
<td>string</td>
<td>Horizontal alignment (<code class="docutils literal notranslate"><span class="pre">center</span></code>, <code class="docutils literal notranslate"><span class="pre">right</span></code>, <code class="docutils literal notranslate"><span class="pre">justify</span></code> or <code class="docutils literal notranslate"><span class="pre">left</span></code> (default))</td>
</tr>
<tr class="row-even"><td>italic</td>
<td>bool</td>
<td>Whether to use an italic font (default: <code class="docutils literal notranslate"><span class="pre">false</span></code>)</td>
</tr>
<tr class="row-odd"><td>kerning</td>
<td>bool</td>
<td>Whether to use kerning when placing characters (default: <code class="docutils literal notranslate"><span class="pre">true</span></code>)</td>
</tr>
<tr class="row-even"><td>pixelsize</td>
<td>int</td>
<td>Pixel size of font (default: 16)</td>
</tr>
<tr class="row-odd"><td>strikeout</td>
<td>bool</td>
<td>Whether to strike out the text (default: <code class="docutils literal notranslate"><span class="pre">false</span></code>)</td>
</tr>
<tr class="row-even"><td>text</td>
<td>string</td>
<td>Text</td>
</tr>
<tr class="row-odd"><td>underline</td>
<td>bool</td>
<td>Whether to underline the text (default: <code class="docutils literal notranslate"><span class="pre">false</span></code>)</td>
</tr>
<tr class="row-even"><td>valign</td>
<td>string</td>
<td>Vertical alignment (<code class="docutils literal notranslate"><span class="pre">center</span></code>, <code class="docutils literal notranslate"><span class="pre">bottom</span></code> or <code class="docutils literal notranslate"><span class="pre">top</span></code> (default))</td>
</tr>
<tr class="row-odd"><td>wrap</td>
<td>bool</td>
<td>Whether the text is wrapped within the object bounds (default: <code class="docutils literal notranslate"><span class="pre">false</span></code>)</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="tileset">
<span id="json-tileset"></span><h3>Tileset<a class="headerlink" href="#tileset" title="Permalink to this headline">¶</a></h3>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>backgroundcolor</td>
<td>string</td>
<td>Hex-formatted color (#RRGGBB or #AARRGGBB) (optional)</td>
</tr>
<tr class="row-odd"><td>columns</td>
<td>int</td>
<td>The number of tile columns in the tileset</td>
</tr>
<tr class="row-even"><td>firstgid</td>
<td>int</td>
<td>GID corresponding to the first tile in the set</td>
</tr>
<tr class="row-odd"><td>grid</td>
<td><a class="reference internal" href="#json-tileset-grid"><span class="std std-ref">Grid</span></a></td>
<td>(optional)</td>
</tr>
<tr class="row-even"><td>image</td>
<td>string</td>
<td>Image used for tiles in this set</td>
</tr>
<tr class="row-odd"><td>imageheight</td>
<td>int</td>
<td>Height of source image in pixels</td>
</tr>
<tr class="row-even"><td>imagewidth</td>
<td>int</td>
<td>Width of source image in pixels</td>
</tr>
<tr class="row-odd"><td>margin</td>
<td>int</td>
<td>Buffer between image edge and first tile (pixels)</td>
</tr>
<tr class="row-even"><td>name</td>
<td>string</td>
<td>Name given to this tileset</td>
</tr>
<tr class="row-odd"><td>objectalignment</td>
<td>string</td>
<td>Alignment to use for tile objects (<code class="docutils literal notranslate"><span class="pre">unspecified</span></code> (default), <code class="docutils literal notranslate"><span class="pre">topleft</span></code>, <code class="docutils literal notranslate"><span class="pre">top</span></code>, <code class="docutils literal notranslate"><span class="pre">topright</span></code>, <code class="docutils literal notranslate"><span class="pre">left</span></code>, <code class="docutils literal notranslate"><span class="pre">center</span></code>, <code class="docutils literal notranslate"><span class="pre">right</span></code>, <code class="docutils literal notranslate"><span class="pre">bottomleft</span></code>, <code class="docutils literal notranslate"><span class="pre">bottom</span></code> or <code class="docutils literal notranslate"><span class="pre">bottomright</span></code>) (since 1.4)</td>
</tr>
<tr class="row-even"><td>properties</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-property"><span class="std std-ref">Properties</span></a></td>
</tr>
<tr class="row-odd"><td>source</td>
<td>string</td>
<td>The external file that contains this tilesets data</td>
</tr>
<tr class="row-even"><td>spacing</td>
<td>int</td>
<td>Spacing between adjacent tiles in image (pixels)</td>
</tr>
<tr class="row-odd"><td>terrains</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-terrain"><span class="std std-ref">Terrains</span></a> (optional)</td>
</tr>
<tr class="row-even"><td>tilecount</td>
<td>int</td>
<td>The number of tiles in this tileset</td>
</tr>
<tr class="row-odd"><td>tiledversion</td>
<td>string</td>
<td>The Tiled version used to save the file</td>
</tr>
<tr class="row-even"><td>tileheight</td>
<td>int</td>
<td>Maximum height of tiles in this set</td>
</tr>
<tr class="row-odd"><td>tileoffset</td>
<td><a class="reference internal" href="#json-tileset-tileoffset"><span class="std std-ref">Tile Offset</span></a></td>
<td>(optional)</td>
</tr>
<tr class="row-even"><td>tiles</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-tile"><span class="std std-ref">Tiles</span></a> (optional)</td>
</tr>
<tr class="row-odd"><td>tilewidth</td>
<td>int</td>
<td>Maximum width of tiles in this set</td>
</tr>
<tr class="row-even"><td>transparentcolor</td>
<td>string</td>
<td>Hex-formatted color (#RRGGBB) (optional)</td>
</tr>
<tr class="row-odd"><td>type</td>
<td>string</td>
<td><code class="docutils literal notranslate"><span class="pre">tileset</span></code> (for tileset files, since 1.0)</td>
</tr>
<tr class="row-even"><td>version</td>
<td>number</td>
<td>The JSON format version</td>
</tr>
<tr class="row-odd"><td>wangsets</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-wangset"><span class="std std-ref">Wang sets</span></a> (since 1.1.5)</td>
</tr>
</tbody>
</table>
<p>Each tileset has a <code class="docutils literal notranslate"><span class="pre">firstgid</span></code> (first global ID) property which
tells you the global ID of its first tile (the one with local
tile ID 0). This allows you to map the global IDs back to the
right tileset, and then calculate the local tile ID by
subtracting the <code class="docutils literal notranslate"><span class="pre">firstgid</span></code> from the global tile ID. The first
tileset always has a <code class="docutils literal notranslate"><span class="pre">firstgid</span></code> value of 1.</p>
<div class="section" id="grid">
<span id="json-tileset-grid"></span><h4>Grid<a class="headerlink" href="#grid" title="Permalink to this headline">¶</a></h4>
<p>Specifies common grid settings used for tiles in a tileset. See
<a class="reference internal" href="index.html#tmx-grid"><span class="std std-ref">&lt;grid&gt;</span></a> in the TMX Map Format.</p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>height</td>
<td>int</td>
<td>Cell height of tile grid</td>
</tr>
<tr class="row-odd"><td>orientation</td>
<td>string</td>
<td><code class="docutils literal notranslate"><span class="pre">orthogonal</span></code> (default) or <code class="docutils literal notranslate"><span class="pre">isometric</span></code></td>
</tr>
<tr class="row-even"><td>width</td>
<td>int</td>
<td>Cell width of tile grid</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="tile-offset">
<span id="json-tileset-tileoffset"></span><h4>Tile Offset<a class="headerlink" href="#tile-offset" title="Permalink to this headline">¶</a></h4>
<p>See <a class="reference internal" href="index.html#tmx-tileoffset"><span class="std std-ref">&lt;tileoffset&gt;</span></a> in the TMX Map Format.</p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>x</td>
<td>int</td>
<td>Horizontal offset in pixels</td>
</tr>
<tr class="row-odd"><td>y</td>
<td>int</td>
<td>Vertical offset in pixels (positive is down)</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="tileset-example">
<h4>Tileset Example<a class="headerlink" href="#tileset-example" title="Permalink to this headline">¶</a></h4>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
 <span class="s2">&quot;columns&quot;</span><span class="p">:</span><span class="mi">19</span><span class="p">,</span>
 <span class="s2">&quot;firstgid&quot;</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span>
 <span class="s2">&quot;image&quot;</span><span class="p">:</span><span class="s2">&quot;..\/image\/fishbaddie_parts.png&quot;</span><span class="p">,</span>
 <span class="s2">&quot;imageheight&quot;</span><span class="p">:</span><span class="mi">480</span><span class="p">,</span>
 <span class="s2">&quot;imagewidth&quot;</span><span class="p">:</span><span class="mi">640</span><span class="p">,</span>
 <span class="s2">&quot;margin&quot;</span><span class="p">:</span><span class="mi">3</span><span class="p">,</span>
 <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
 <span class="s2">&quot;properties&quot;</span><span class="p">:[</span>
   <span class="p">{</span>
     <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;myProperty1&quot;</span><span class="p">,</span>
     <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;string&quot;</span><span class="p">,</span>
     <span class="s2">&quot;value&quot;</span><span class="p">:</span><span class="s2">&quot;myProperty1_value&quot;</span>
   <span class="p">}],</span>
 <span class="s2">&quot;spacing&quot;</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span>
 <span class="s2">&quot;tilecount&quot;</span><span class="p">:</span><span class="mi">266</span><span class="p">,</span>
 <span class="s2">&quot;tileheight&quot;</span><span class="p">:</span><span class="mi">32</span><span class="p">,</span>
 <span class="s2">&quot;tilewidth&quot;</span><span class="p">:</span><span class="mi">32</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="tile-definition">
<span id="json-tile"></span><h4>Tile (Definition)<a class="headerlink" href="#tile-definition" title="Permalink to this headline">¶</a></h4>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>animation</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-frame"><span class="std std-ref">Frames</span></a></td>
</tr>
<tr class="row-odd"><td>id</td>
<td>int</td>
<td>Local ID of the tile</td>
</tr>
<tr class="row-even"><td>image</td>
<td>string</td>
<td>Image representing this tile (optional)</td>
</tr>
<tr class="row-odd"><td>imageheight</td>
<td>int</td>
<td>Height of the tile image in pixels</td>
</tr>
<tr class="row-even"><td>imagewidth</td>
<td>int</td>
<td>Width of the tile image in pixels</td>
</tr>
<tr class="row-odd"><td>objectgroup</td>
<td><a class="reference internal" href="#json-layer"><span class="std std-ref">Layer</span></a></td>
<td>Layer with type <code class="docutils literal notranslate"><span class="pre">objectgroup</span></code>, when collision shapes are specified (optional)</td>
</tr>
<tr class="row-even"><td>probability</td>
<td>double</td>
<td>Percentage chance this tile is chosen when competing with others in the editor (optional)</td>
</tr>
<tr class="row-odd"><td>properties</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-property"><span class="std std-ref">Properties</span></a></td>
</tr>
<tr class="row-even"><td>terrain</td>
<td>array</td>
<td>Index of terrain for each corner of tile (optional)</td>
</tr>
<tr class="row-odd"><td>type</td>
<td>string</td>
<td>The type of the tile (optional)</td>
</tr>
</tbody>
</table>
<p>A tileset that associates information with each tile, like its image
path or terrain type, may include a <code class="docutils literal notranslate"><span class="pre">tiles</span></code> array property. Each tile
has an <code class="docutils literal notranslate"><span class="pre">id</span></code> property, which specifies the local ID within the tileset.</p>
<p>For the terrain information, each value is a length-4 array where each
element is the index of a <a class="reference internal" href="#json-terrain"><span class="std std-ref">terrain</span></a> on one corner
of the tile. The order of indices is: top-left, top-right, bottom-left,
bottom-right.</p>
<p>Example:</p>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s2">&quot;tiles&quot;</span><span class="p">:[</span>
  <span class="p">{</span>
    <span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span>
    <span class="s2">&quot;properties&quot;</span><span class="p">:[</span>
      <span class="p">{</span>
        <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;myProperty1&quot;</span><span class="p">,</span>
        <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;string&quot;</span><span class="p">,</span>
        <span class="s2">&quot;value&quot;</span><span class="p">:</span><span class="s2">&quot;myProperty1_value&quot;</span>
      <span class="p">}],</span>
    <span class="s2">&quot;terrain&quot;</span><span class="p">:[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
  <span class="p">},</span>
  <span class="p">{</span>
    <span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="mi">11</span><span class="p">,</span>
    <span class="s2">&quot;properties&quot;</span><span class="p">:[</span>
      <span class="p">{</span>
        <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;myProperty2&quot;</span><span class="p">,</span>
        <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;string&quot;</span><span class="p">,</span>
        <span class="s2">&quot;value&quot;</span><span class="p">:</span><span class="s2">&quot;myProperty2_value&quot;</span>
      <span class="p">}],</span>
    <span class="s2">&quot;terrain&quot;</span><span class="p">:[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span>
  <span class="p">},</span>
  <span class="p">{</span>
    <span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="mi">12</span><span class="p">,</span>
    <span class="s2">&quot;properties&quot;</span><span class="p">:[</span>
      <span class="p">{</span>
        <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;myProperty3&quot;</span><span class="p">,</span>
        <span class="s2">&quot;type&quot;</span><span class="p">:</span><span class="s2">&quot;string&quot;</span><span class="p">,</span>
        <span class="s2">&quot;value&quot;</span><span class="p">:</span><span class="s2">&quot;myProperty3_value&quot;</span>
      <span class="p">}],</span>
    <span class="s2">&quot;terrain&quot;</span><span class="p">:[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span>
  <span class="p">}</span>
<span class="p">]</span>
</pre></div>
</div>
</div>
<div class="section" id="frame">
<span id="json-frame"></span><h4>Frame<a class="headerlink" href="#frame" title="Permalink to this headline">¶</a></h4>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>duration</td>
<td>int</td>
<td>Frame duration in milliseconds</td>
</tr>
<tr class="row-odd"><td>tileid</td>
<td>int</td>
<td>Local tile ID representing this frame</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="terrain">
<span id="json-terrain"></span><h4>Terrain<a class="headerlink" href="#terrain" title="Permalink to this headline">¶</a></h4>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>name</td>
<td>string</td>
<td>Name of terrain</td>
</tr>
<tr class="row-odd"><td>properties</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-property"><span class="std std-ref">Properties</span></a></td>
</tr>
<tr class="row-even"><td>tile</td>
<td>int</td>
<td>Local ID of tile representing terrain</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s2">&quot;terrains&quot;</span><span class="p">:[</span>
<span class="p">{</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;ground&quot;</span><span class="p">,</span>
  <span class="s2">&quot;tile&quot;</span><span class="p">:</span><span class="mi">0</span>
<span class="p">},</span>
<span class="p">{</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;chasm&quot;</span><span class="p">,</span>
  <span class="s2">&quot;tile&quot;</span><span class="p">:</span><span class="mi">12</span>
<span class="p">},</span>
<span class="p">{</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span><span class="s2">&quot;cliff&quot;</span><span class="p">,</span>
  <span class="s2">&quot;tile&quot;</span><span class="p">:</span><span class="mi">36</span>
<span class="p">}],</span>
</pre></div>
</div>
</div>
<div class="section" id="wang-set">
<span id="json-wangset"></span><h4>Wang Set<a class="headerlink" href="#wang-set" title="Permalink to this headline">¶</a></h4>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>cornercolors</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-wangcolor"><span class="std std-ref">Wang colors</span></a></td>
</tr>
<tr class="row-odd"><td>edgecolors</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-wangcolor"><span class="std std-ref">Wang colors</span></a></td>
</tr>
<tr class="row-even"><td>name</td>
<td>string</td>
<td>Name of the Wang set</td>
</tr>
<tr class="row-odd"><td>properties</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-property"><span class="std std-ref">Properties</span></a></td>
</tr>
<tr class="row-even"><td>tile</td>
<td>int</td>
<td>Local ID of tile representing the Wang set</td>
</tr>
<tr class="row-odd"><td>wangtiles</td>
<td>array</td>
<td>Array of <a class="reference internal" href="#json-wangtile"><span class="std std-ref">Wang tiles</span></a></td>
</tr>
</tbody>
</table>
<div class="section" id="wang-color">
<span id="json-wangcolor"></span><h5>Wang Color<a class="headerlink" href="#wang-color" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>color</td>
<td>string</td>
<td>Hex-formatted color (#RRGGBB or #AARRGGBB)</td>
</tr>
<tr class="row-odd"><td>name</td>
<td>string</td>
<td>Name of the Wang color</td>
</tr>
<tr class="row-even"><td>probability</td>
<td>double</td>
<td>Probability used when randomizing</td>
</tr>
<tr class="row-odd"><td>tile</td>
<td>int</td>
<td>Local ID of tile representing the Wang color</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;color&quot;</span><span class="p">:</span> <span class="s2">&quot;#d31313&quot;</span><span class="p">,</span>
  <span class="s2">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Rails&quot;</span><span class="p">,</span>
  <span class="s2">&quot;probability&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
  <span class="s2">&quot;tile&quot;</span><span class="p">:</span> <span class="mi">18</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="wang-tile">
<span id="json-wangtile"></span><h5>Wang Tile<a class="headerlink" href="#wang-tile" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>dflip</td>
<td>bool</td>
<td>Tile is flipped diagonally (default: <code class="docutils literal notranslate"><span class="pre">false</span></code>)</td>
</tr>
<tr class="row-odd"><td>hflip</td>
<td>bool</td>
<td>Tile is flipped horizontally (default: <code class="docutils literal notranslate"><span class="pre">false</span></code>)</td>
</tr>
<tr class="row-even"><td>tileid</td>
<td>int</td>
<td>Local ID of tile</td>
</tr>
<tr class="row-odd"><td>vflip</td>
<td>bool</td>
<td>Tile is flipped vertically (default: <code class="docutils literal notranslate"><span class="pre">false</span></code>)</td>
</tr>
<tr class="row-even"><td>wangid</td>
<td>array</td>
<td>Array of Wang color indexes (<code class="docutils literal notranslate"><span class="pre">uchar[8]</span></code>)</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="code json highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  <span class="s2">&quot;dflip&quot;</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
  <span class="s2">&quot;hflip&quot;</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
  <span class="s2">&quot;tileid&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
  <span class="s2">&quot;vflip&quot;</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
  <span class="s2">&quot;wangid&quot;</span><span class="p">:</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="object-template">
<span id="json-objecttemplate"></span><h3>Object Template<a class="headerlink" href="#object-template" title="Permalink to this headline">¶</a></h3>
<p>An object template is written to its own file and referenced by any
instances of that template.</p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>type</td>
<td>string</td>
<td><code class="docutils literal notranslate"><span class="pre">template</span></code></td>
</tr>
<tr class="row-odd"><td>tileset</td>
<td><a class="reference internal" href="#json-tileset"><span class="std std-ref">Tileset</span></a></td>
<td>External tileset used by the template (optional)</td>
</tr>
<tr class="row-even"><td>object</td>
<td><a class="reference internal" href="#json-object"><span class="std std-ref">Object</span></a></td>
<td>The object instantiated by this template</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="property">
<span id="json-property"></span><h3>Property<a class="headerlink" href="#property" title="Permalink to this headline">¶</a></h3>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>name</td>
<td>string</td>
<td>Name of the property</td>
</tr>
<tr class="row-odd"><td>type</td>
<td>string</td>
<td>Type of the property (<code class="docutils literal notranslate"><span class="pre">string</span></code> (default), <code class="docutils literal notranslate"><span class="pre">int</span></code>, <code class="docutils literal notranslate"><span class="pre">float</span></code>, <code class="docutils literal notranslate"><span class="pre">bool</span></code>, <code class="docutils literal notranslate"><span class="pre">color</span></code> or <code class="docutils literal notranslate"><span class="pre">file</span></code> (since 0.16, with <code class="docutils literal notranslate"><span class="pre">color</span></code> and <code class="docutils literal notranslate"><span class="pre">file</span></code> added in 0.17))</td>
</tr>
<tr class="row-even"><td>value</td>
<td>value</td>
<td>Value of the property</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="point">
<span id="json-point"></span><h3>Point<a class="headerlink" href="#point" title="Permalink to this headline">¶</a></h3>
<p>A point on a polygon or a polyline, relative to the position of the object.</p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="17%" />
<col width="17%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field</th>
<th class="head">Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>x</td>
<td>double</td>
<td>X coordinate in pixels</td>
</tr>
<tr class="row-odd"><td>y</td>
<td>double</td>
<td>Y coordinate in pixels</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="changelog">
<h3>Changelog<a class="headerlink" href="#changelog" title="Permalink to this headline">¶</a></h3>
<div class="section" id="tiled-1-4">
<h4>Tiled 1.4<a class="headerlink" href="#tiled-1-4" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Added <code class="docutils literal notranslate"><span class="pre">objectalignment</span></code> to the <a class="reference internal" href="#json-tileset"><span class="std std-ref">Tileset</span></a> object.</li>
<li>Added <code class="docutils literal notranslate"><span class="pre">tintcolor</span></code> to the <a class="reference internal" href="#json-layer"><span class="std std-ref">Layer</span></a> object.</li>
</ul>
</div>
<div class="section" id="tiled-1-3">
<h4>Tiled 1.3<a class="headerlink" href="#tiled-1-3" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Added an <code class="docutils literal notranslate"><span class="pre">editorsettings</span></code> property to top-level <a class="reference internal" href="#json-map"><span class="std std-ref">Map</span></a> and
<a class="reference internal" href="#json-tileset"><span class="std std-ref">Tileset</span></a> objects, which is used to store editor specific settings
that are generally not relevant when loading a map or tileset.</li>
<li>Added support for Zstandard compression for tile layer data
(<code class="docutils literal notranslate"><span class="pre">&quot;compression&quot;:</span> <span class="pre">&quot;zstd&quot;</span></code> on <a class="reference internal" href="#json-layer"><span class="std std-ref">tile layer objects</span></a>).</li>
<li>Added the <code class="docutils literal notranslate"><span class="pre">compressionlevel</span></code> property to the <a class="reference internal" href="#json-map"><span class="std std-ref">Map</span></a> object,
which stores the compression level to use for compressed tile layer data.</li>
</ul>
</div>
<div class="section" id="tiled-1-2">
<h4>Tiled 1.2<a class="headerlink" href="#tiled-1-2" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Added <code class="docutils literal notranslate"><span class="pre">nextlayerid</span></code> to the <a class="reference internal" href="#json-map"><span class="std std-ref">Map</span></a> object.</li>
<li>Added <code class="docutils literal notranslate"><span class="pre">id</span></code> to the <a class="reference internal" href="#json-layer"><span class="std std-ref">Layer</span></a> object.</li>
<li>The tiles in a <a class="reference internal" href="#json-tileset"><span class="std std-ref">Tileset</span></a> are now stored as an array instead
of an object. Previously the tile IDs were stored as string keys of
the “tiles” object, now they are stored as <code class="docutils literal notranslate"><span class="pre">id</span></code> property of each
<a class="reference internal" href="#json-tile"><span class="std std-ref">Tile</span></a> object.</li>
<li>Custom tile properties are now stored within each
<a class="reference internal" href="#json-tile"><span class="std std-ref">Tile</span></a> instead of being included as
<code class="docutils literal notranslate"><span class="pre">tileproperties</span></code> in the <a class="reference internal" href="#json-tileset"><span class="std std-ref">Tileset</span></a> object.</li>
<li>Custom properties are now stored in an array instead of an object
where the property names were the keys. Each property is now an object
that stores the name, type and value of the property. The separate
<code class="docutils literal notranslate"><span class="pre">propertytypes</span></code> and <code class="docutils literal notranslate"><span class="pre">tilepropertytypes</span></code> attributes have been
removed.</li>
</ul>
</div>
<div class="section" id="tiled-1-1">
<h4>Tiled 1.1<a class="headerlink" href="#tiled-1-1" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Added a <a class="reference internal" href="#json-chunk"><span class="std std-ref">chunked data format</span></a>, currently used for
<a class="reference internal" href="index.html#document-manual/using-infinite-maps"><span class="doc">infinite maps</span></a>.</li>
<li><a class="reference internal" href="index.html#document-manual/using-templates"><span class="doc">Templates</span></a> were added. Templates can
be stored as JSON files with an <a class="reference internal" href="#json-objecttemplate"><span class="std std-ref">Object Template</span></a> object.</li>
<li><a class="reference internal" href="#json-tileset"><span class="std std-ref">Tilesets</span></a> can now contain
<a class="reference internal" href="index.html#document-manual/using-wang-tiles"><span class="doc">Wang tiles</span></a>. They are saved in the
new <a class="reference internal" href="#json-wangset"><span class="std std-ref">Wang Set</span></a> object (since Tiled 1.1.5).</li>
</ul>
</div>
</div>
</div>
<span id="document-reference/scripting"></span><div class="new new-prev">Since Tiled 1.3</div><div class="section" id="scripting">
<h2>Scripting<a class="headerlink" href="#scripting" title="Permalink to this headline">¶</a></h2>
<div class="section" id="introduction">
<h3>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h3>
<p>Tiled can be extended with the use of JavaScript. Scripts can be used to
implement <a class="reference internal" href="#script-registermapformat"><span class="std std-ref">custom map formats</span></a>,
<a class="reference internal" href="#script-registeraction"><span class="std std-ref">custom actions</span></a> and <a class="reference internal" href="#script-registertool"><span class="std std-ref">new tools</span></a>.
Scripts can also <a class="reference internal" href="#script-connecting-to-signals"><span class="std std-ref">automate actions based on signals</span></a>.</p>
<p>On startup, Tiled will execute any script files present in
<a class="reference internal" href="#script-extensions"><span class="std std-ref">extensions</span></a>. In addition it is possible to run
scripts directly from <a class="reference internal" href="#script-console"><span class="std std-ref">the console</span></a>. All scripts share
a single JavaScript context.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">A few example scripts and links to existing Tiled extensions are provided
at the Tiled Extensions repository: <a class="reference external" href="https://github.com/mapeditor/tiled-extensions">https://github.com/mapeditor/tiled-extensions</a></p>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Most builds of Tiled use Qt 5.12 or later, which support ECMAScript 7.
However, the builds for Windows XP and the snap release of Tiled currently
rely on Qt 5.6 and Qt 5.9 respectively. ECMAScript 7 features will not
work there and some other functionality is missing as well, like
interrupting scripts on API usage errors and the creation of new
Tiled-specific objects.</p>
</div>
<div class="section" id="scripted-extensions">
<span id="script-extensions"></span><h4>Scripted Extensions<a class="headerlink" href="#scripted-extensions" title="Permalink to this headline">¶</a></h4>
<p>Extensions are placed in a system-specific location. This folder can be opened
from the Plugins tab in the <a class="reference internal" href="index.html#document-manual/preferences"><span class="doc">Preferences dialog</span></a>.</p>
<table border="1" class="docutils">
<colgroup>
<col width="17%" />
<col width="83%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>Windows</strong></td>
<td><div class="first last line-block">
<div class="line"><code class="file docutils literal notranslate"><span class="pre">C:/Users/&lt;USER&gt;/AppData/Local/Tiled/extensions/</span></code></div>
</div>
</td>
</tr>
<tr class="row-even"><td><strong>macOS</strong></td>
<td><div class="first last line-block">
<div class="line"><code class="file docutils literal notranslate"><span class="pre">~/Library/Preferences/Tiled/extensions/</span></code></div>
</div>
</td>
</tr>
<tr class="row-odd"><td><strong>Linux</strong></td>
<td><div class="first last line-block">
<div class="line"><code class="file docutils literal notranslate"><span class="pre">~/.config/tiled/extensions/</span></code></div>
</div>
</td>
</tr>
</tbody>
</table>
<p>An extension can be placed directly in the extensions directory, or in a
sub-directory. All scripts files found in these directories are executed on
startup.</p>
<p>When any loaded script is changed or when any files are added/removed from the
extensions directory, the script engine is automatically reinstantiated and the
scripts are reloaded. This way there is no need to restart Tiled when
installing extensions. It also makes it quick to iterate on a script until it
works as intended.</p>
<p>Apart from scripts, extensions can include images that can be used as the icon
for scripted actions or tools.</p>
</div>
<div class="section" id="console-view">
<span id="script-console"></span><h4>Console View<a class="headerlink" href="#console-view" title="Permalink to this headline">¶</a></h4>
<p>In the Console view (<em>View &gt; Views and Toolbars &gt; Console</em>) you will
find a text entry where you can write or paste scripts to evaluate them.</p>
<p>You can use the Up/Down keys to navigate through previously entered
script expressions.</p>
</div>
<div class="section" id="connecting-to-signals">
<span id="script-connecting-to-signals"></span><h4>Connecting to Signals<a class="headerlink" href="#connecting-to-signals" title="Permalink to this headline">¶</a></h4>
<p>The script API provides signals to which functions can be connected.
Currently, the tiled module has the most useful <a class="reference internal" href="#script-tiled-signals"><span class="std std-ref">set of signals</span></a>.</p>
<p>Properties usually will have related signals which can be used to detect
changes to that property, but most of those are currently not
implemented.</p>
<p>To connect to a signal, call its <code class="docutils literal notranslate"><span class="pre">connect</span></code> function and pass in a
function object. In the following example, newly created maps
automatically get their first tile layer removed:</p>
<div class="code js highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">tiled</span><span class="o">.</span><span class="n">assetCreated</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">asset</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">asset</span><span class="o">.</span><span class="n">layerCount</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
        <span class="n">asset</span><span class="o">.</span><span class="n">removeLayerAt</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
        <span class="n">tiled</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="s2">&quot;assetCreated: Removed automatically added tile layer.&quot;</span><span class="p">)</span>
    <span class="p">}</span>
<span class="p">})</span>
</pre></div>
</div>
<p>In some cases it will be necessary to later disconnect the function from
the signal again. This can be done by defining the function separately
and passing it into the <code class="docutils literal notranslate"><span class="pre">disconnect</span></code> function:</p>
<div class="code js highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">function</span> <span class="n">onAssetCreated</span><span class="p">(</span><span class="n">asset</span><span class="p">)</span> <span class="p">{</span>
    <span class="o">//</span> <span class="n">Do</span> <span class="n">something</span><span class="o">...</span>
<span class="p">}</span>

<span class="n">tiled</span><span class="o">.</span><span class="n">assetCreated</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">onAssetCreated</span><span class="p">)</span>
<span class="o">//</span> <span class="o">...</span>
<span class="n">tiled</span><span class="o">.</span><span class="n">assetCreated</span><span class="o">.</span><span class="n">disconnect</span><span class="p">(</span><span class="n">onAssetCreated</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="api-reference">
<h3>API Reference<a class="headerlink" href="#api-reference" title="Permalink to this headline">¶</a></h3>
<div class="section" id="global-variables">
<h4>Global Variables<a class="headerlink" href="#global-variables" title="Permalink to this headline">¶</a></h4>
<dl class="docutils">
<dt>__filename</dt>
<dd>The file path of the current file being evaluated. Only available during
initial evaluation of the file and not when later functions in that file
get called. If you need it there, copy the value to local scope.</dd>
</dl>
</div>
<div class="section" id="tiled-module">
<h4>tiled module<a class="headerlink" href="#tiled-module" title="Permalink to this headline">¶</a></h4>
<p>The <code class="docutils literal notranslate"><span class="pre">tiled</span></code> module is the main entry point and provides properties,
functions and signals which are documented below.</p>
<div class="section" id="properties">
<h5>Properties<a class="headerlink" href="#properties" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>version</strong> : string <em>[read‑only]</em></td>
<td>Currently used version of Tiled.</td>
</tr>
<tr class="row-even"><td><strong>platform</strong> : string <em>[read‑only]</em></td>
<td>Operating system. One of <code class="docutils literal notranslate"><span class="pre">windows</span></code>, <code class="docutils literal notranslate"><span class="pre">macos</span></code>, <code class="docutils literal notranslate"><span class="pre">linux</span></code> or <code class="docutils literal notranslate"><span class="pre">unix</span></code>
(for any other UNIX-like system).</td>
</tr>
<tr class="row-odd"><td><strong>arch</strong> : string <em>[read‑only]</em></td>
<td>Processor architecture. One of <code class="docutils literal notranslate"><span class="pre">x64</span></code>, <code class="docutils literal notranslate"><span class="pre">x86</span></code> or <code class="docutils literal notranslate"><span class="pre">unknown</span></code>.</td>
</tr>
<tr class="row-even"><td><strong>actions</strong> : [string] <em>[read‑only]</em></td>
<td>Available actions for <a class="reference internal" href="#script-trigger"><span class="std std-ref">tiled.trigger()</span></a>.</td>
</tr>
<tr class="row-odd"><td><strong>menus</strong> : [string] <em>[read‑only]</em></td>
<td>Available menus for <a class="reference internal" href="#script-extendmenu"><span class="std std-ref">tiled.extendMenu()</span></a>.</td>
</tr>
<tr class="row-even"><td><strong>activeAsset</strong> : <a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a></td>
<td>Currently selected asset, or <code class="docutils literal notranslate"><span class="pre">null</span></code> if no file is open. Can be assigned
any open asset in order to change the active asset.</td>
</tr>
<tr class="row-odd"><td><strong>openAssets</strong> : array <em>[read‑only]</em></td>
<td>List of currently opened <a class="reference internal" href="#script-asset"><span class="std std-ref">assets</span></a>.</td>
</tr>
<tr class="row-even"><td><strong>mapEditor</strong> : <a class="reference internal" href="#script-mapeditor"><span class="std std-ref">MapEditor</span></a></td>
<td>Access the editor used when editing maps.</td>
</tr>
<tr class="row-odd"><td><strong>tilesetEditor</strong> : <a class="reference internal" href="#script-tileseteditor"><span class="std std-ref">TilesetEditor</span></a></td>
<td>Access the editor used when editing tilesets.</td>
</tr>
<tr class="row-even"><td><strong>tilesetFormats</strong> : [string] <em>[read‑only]</em></td>
<td>List of supported tileset format names. Use
<a class="reference internal" href="#script-tilesetformat"><span class="std std-ref">tilesetFormat</span></a> to get the corresponding format object
to read and write files. (Since 1.4)</td>
</tr>
<tr class="row-odd"><td><strong>mapFormats</strong> : [string] <em>[read‑only]</em></td>
<td>List of supported map format names. Use
<a class="reference internal" href="#script-mapformat"><span class="std std-ref">mapFormat</span></a> to get the corresponding format object to
read and write files. (Since 1.4)</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="functions">
<h5>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h5>
<dl class="docutils" id="script-trigger">
<dt>tiled.trigger(action <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">This function can be used to trigger any registered action. This
includes most actions you would normally trigger through the menu or by
using their shortcut.</p>
<p>Use the <code class="docutils literal notranslate"><span class="pre">tiled.actions</span></code> property to get a list of all available actions.</p>
<p class="last">Actions that are checkable will toggle when triggered.</p>
</dd>
</dl>
<dl class="docutils" id="script-execute">
<dt>tiled.executeCommand(name <span class="classifier-delimiter">:</span> <span class="classifier">string, inTerminal</span> <span class="classifier-delimiter">:</span> <span class="classifier">bool)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Executes the first custom command with the given name, as if it was
triggered manually. Works also with commands that are not currently enabled.</p>
<p class="last">Raises a script error if the command is not found.</p>
</dd>
</dl>
<dl class="docutils" id="script-open">
<dt>tiled.open(fileName <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a></span></dt>
<dd>Requests to open the asset with the given file name. Returns a reference to
the opened asset, or <code class="docutils literal notranslate"><span class="pre">null</span></code> in case there was a problem.</dd>
</dl>
<dl class="docutils" id="script-close">
<dt>tiled.close(asset <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">bool</span></dt>
<dd>Closes the given asset without checking for unsaved changes (to confirm the
loss of any unsaved changes, set <code class="docutils literal notranslate"><span class="pre">activeAsset</span></code> and trigger the “Close”
action instead).</dd>
</dl>
<dl class="docutils" id="script-reload">
<dt>tiled.reload(asset <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a></span></dt>
<dd>Reloads the given asset from disk, without checking for unsaved changes.
This invalidates the previous script reference to the asset, hence the new
reference is returned for convenience. Returns <code class="docutils literal notranslate"><span class="pre">null</span></code> if reloading failed.</dd>
<dt>tiled.alert(text <span class="classifier-delimiter">:</span> <span class="classifier">string [, title</span> <span class="classifier-delimiter">:</span> <span class="classifier">string])</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Shows a modal warning dialog to the user with the given text and
optional title.</dd>
<dt>tiled.confirm(text <span class="classifier-delimiter">:</span> <span class="classifier">string [, title</span> <span class="classifier-delimiter">:</span> <span class="classifier">string])</span> <span class="classifier-delimiter">:</span> <span class="classifier">bool</span></dt>
<dd>Shows a yes/no dialog to the user with the given text and optional
title. Returns <code class="docutils literal notranslate"><span class="pre">true</span></code> or <code class="docutils literal notranslate"><span class="pre">false</span></code>.</dd>
<dt>tiled.prompt(label <span class="classifier-delimiter">:</span> <span class="classifier">string [, text</span> <span class="classifier-delimiter">:</span> <span class="classifier">string [, title</span> <span class="classifier-delimiter">:</span> <span class="classifier">string]])</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Shows a dialog that asks the user to enter some text, along with the
given label and optional title. The optional <code class="docutils literal notranslate"><span class="pre">text</span></code> parameter provides
the initial value of the text. Returns the entered text.</dd>
<dt>tiled.log(text <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Outputs the given text in the Console window as regular text.</dd>
<dt>tiled.warn(text <span class="classifier-delimiter">:</span> <span class="classifier">string, activated</span> <span class="classifier-delimiter">:</span> <span class="classifier">function)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Outputs the given text in the Console window as warning message and creates
an issue in the Issues window.</p>
<p class="last">When the issue is activated (with double-click or Enter key) the given
callback function is invoked.</p>
</dd>
<dt>tiled.error(text <span class="classifier-delimiter">:</span> <span class="classifier">string, activated</span> <span class="classifier-delimiter">:</span> <span class="classifier">function)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Outputs the given text in the Console window as error message and creates
an issue in the Issues window.</p>
<p class="last">When the issue is activated (with double-click or Enter key) the given
callback function is invoked.</p>
</dd>
</dl>
<dl class="docutils" id="script-registeraction">
<dt>tiled.registerAction(id <span class="classifier-delimiter">:</span> <span class="classifier">string, callback</span> <span class="classifier-delimiter">:</span> <span class="classifier">function)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-action"><span class="std std-ref">Action</span></a></span></dt>
<dd><p class="first">Registers a new action with the given <code class="docutils literal notranslate"><span class="pre">id</span></code> and <code class="docutils literal notranslate"><span class="pre">callback</span></code> (which is
called when the action is triggered). The returned action object can be
used to set (and update) various properties of the action.</p>
<p>Example:</p>
<div class="code javascript highlight-default notranslate"><div class="highlight"><pre><span></span>var action = tiled.registerAction(&quot;CustomAction&quot;, function(action) {
    tiled.log(action.text + &quot; was &quot; + (action.checked ? &quot;checked&quot; : &quot;unchecked&quot;))
})

action.text = &quot;My Custom Action&quot;
action.checkable = true
action.shortcut = &quot;Ctrl+K&quot;
</pre></div>
</div>
<p class="last">The shortcut will currently only work when the action is added to a menu
using <a class="reference internal" href="#script-extendmenu"><span class="std std-ref">tiled.extendMenu()</span></a>.</p>
</dd>
</dl>
<dl class="docutils" id="script-registermapformat">
<dt>tiled.registerMapFormat(shortName <span class="classifier-delimiter">:</span> <span class="classifier">string, mapFormat</span> <span class="classifier-delimiter">:</span> <span class="classifier">object)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Registers a new map format that can then be used to open and/or save maps
in that format.</p>
<p>If a map format is already registered with the same <code class="docutils literal notranslate"><span class="pre">shortName</span></code>,
the existing format is replaced. The short name can also be used to
specify the format when using <code class="docutils literal notranslate"><span class="pre">--export-map</span></code> on the command-line,
in case the file extension is ambiguous or a different one should be
used.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">mapFormat</span></code> object is expected to have the following properties:</p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>name</strong> : string</td>
<td>Name of the format as shown in the file dialog.</td>
</tr>
<tr class="row-even"><td><strong>extension</strong> : string</td>
<td>The file extension used by the format.</td>
</tr>
<tr class="row-odd"><td><strong>read</strong> : function(fileName : string) : <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a></td>
<td>A function
that reads a map from the given file. Can use <a class="reference internal" href="#script-textfile"><span class="std std-ref">TextFile</span></a> or
<a class="reference internal" href="#script-binaryfile"><span class="std std-ref">BinaryFile</span></a> to read the file.</td>
</tr>
<tr class="row-even"><td><strong>write</strong> : function(map : <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a>, fileName : string) : string | undefined</td>
<td>A function
that writes a map to the given file. Can use <a class="reference internal" href="#script-textfile"><span class="std std-ref">TextFile</span></a> or
<a class="reference internal" href="#script-binaryfile"><span class="std std-ref">BinaryFile</span></a> to write the file. When a non-empty string is returned, it is shown as error message.</td>
</tr>
<tr class="row-odd"><td><strong>outputFiles</strong> : function(map : <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a>, fileName : string) : [string]</td>
<td>A function
that returns the list of files that will be written when exporting the given map (optional).</td>
</tr>
</tbody>
</table>
<p>Example that produces a simple JSON representation of a map:</p>
<div class="code javascript last highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">var</span> <span class="n">customMapFormat</span> <span class="o">=</span> <span class="p">{</span>
    <span class="n">name</span><span class="p">:</span> <span class="s2">&quot;Custom map format&quot;</span><span class="p">,</span>
    <span class="n">extension</span><span class="p">:</span> <span class="s2">&quot;custom&quot;</span><span class="p">,</span>

    <span class="n">write</span><span class="p">:</span> <span class="n">function</span><span class="p">(</span><span class="nb">map</span><span class="p">,</span> <span class="n">fileName</span><span class="p">)</span> <span class="p">{</span>
        <span class="n">var</span> <span class="n">m</span> <span class="o">=</span> <span class="p">{</span>
            <span class="n">width</span><span class="p">:</span> <span class="nb">map</span><span class="o">.</span><span class="n">width</span><span class="p">,</span>
            <span class="n">height</span><span class="p">:</span> <span class="nb">map</span><span class="o">.</span><span class="n">height</span><span class="p">,</span>
            <span class="n">layers</span><span class="p">:</span> <span class="p">[]</span>
        <span class="p">};</span>

        <span class="k">for</span> <span class="p">(</span><span class="n">var</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="nb">map</span><span class="o">.</span><span class="n">layerCount</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span> <span class="p">{</span>
            <span class="n">var</span> <span class="n">layer</span> <span class="o">=</span> <span class="nb">map</span><span class="o">.</span><span class="n">layerAt</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">layer</span><span class="o">.</span><span class="n">isTileLayer</span><span class="p">)</span> <span class="p">{</span>
                <span class="n">var</span> <span class="n">rows</span> <span class="o">=</span> <span class="p">[];</span>
                <span class="k">for</span> <span class="p">(</span><span class="n">y</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">y</span> <span class="o">&lt;</span> <span class="n">layer</span><span class="o">.</span><span class="n">height</span><span class="p">;</span> <span class="o">++</span><span class="n">y</span><span class="p">)</span> <span class="p">{</span>
                    <span class="n">var</span> <span class="n">row</span> <span class="o">=</span> <span class="p">[];</span>
                    <span class="k">for</span> <span class="p">(</span><span class="n">x</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">x</span> <span class="o">&lt;</span> <span class="n">layer</span><span class="o">.</span><span class="n">width</span><span class="p">;</span> <span class="o">++</span><span class="n">x</span><span class="p">)</span>
                        <span class="n">row</span><span class="o">.</span><span class="n">push</span><span class="p">(</span><span class="n">layer</span><span class="o">.</span><span class="n">cellAt</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">tileId</span><span class="p">);</span>
                    <span class="n">rows</span><span class="o">.</span><span class="n">push</span><span class="p">(</span><span class="n">row</span><span class="p">);</span>
                <span class="p">}</span>
                <span class="n">m</span><span class="o">.</span><span class="n">layers</span><span class="o">.</span><span class="n">push</span><span class="p">(</span><span class="n">rows</span><span class="p">);</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="n">var</span> <span class="n">file</span> <span class="o">=</span> <span class="n">new</span> <span class="n">TextFile</span><span class="p">(</span><span class="n">fileName</span><span class="p">,</span> <span class="n">TextFile</span><span class="o">.</span><span class="n">WriteOnly</span><span class="p">);</span>
        <span class="n">file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">JSON</span><span class="o">.</span><span class="n">stringify</span><span class="p">(</span><span class="n">m</span><span class="p">));</span>
        <span class="n">file</span><span class="o">.</span><span class="n">commit</span><span class="p">();</span>
    <span class="p">},</span>
<span class="p">}</span>

<span class="n">tiled</span><span class="o">.</span><span class="n">registerMapFormat</span><span class="p">(</span><span class="s2">&quot;custom&quot;</span><span class="p">,</span> <span class="n">customMapFormat</span><span class="p">)</span>
</pre></div>
</div>
</dd>
</dl>
<dl class="docutils" id="script-registertilesetformat">
<dt>tiled.registerTilesetFormat(shortName <span class="classifier-delimiter">:</span> <span class="classifier">string, tilesetFormat</span> <span class="classifier-delimiter">:</span> <span class="classifier">object)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Like <a class="reference internal" href="#script-registermapformat"><span class="std std-ref">registerMapFormat</span></a>, but registers a
custom tileset format instead.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">tilesetFormat</span></code> object is expected to have the following properties:</p>
<table border="1" class="colwidths-given last docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>name</strong> : string</td>
<td>Name of the format as shown in the file dialog.</td>
</tr>
<tr class="row-even"><td><strong>extension</strong> : string</td>
<td>The file extension used by the format.</td>
</tr>
<tr class="row-odd"><td><strong>read</strong> : function(fileName : string) : <a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a></td>
<td>A function
that reads a tileset from the given file. Can use <a class="reference internal" href="#script-textfile"><span class="std std-ref">TextFile</span></a> or
<a class="reference internal" href="#script-binaryfile"><span class="std std-ref">BinaryFile</span></a> to read the file.</td>
</tr>
<tr class="row-even"><td><strong>write</strong> : function(tileset : <a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a>, fileName : string) : string | undefined</td>
<td>A function
that writes a tileset to the given file. Can use <a class="reference internal" href="#script-textfile"><span class="std std-ref">TextFile</span></a> or
<a class="reference internal" href="#script-binaryfile"><span class="std std-ref">BinaryFile</span></a> to write the file. When a non-empty string is returned, it is shown as error message.</td>
</tr>
</tbody>
</table>
</dd>
</dl>
<dl class="docutils" id="script-registertool">
<dt>tiled.registerTool(shortName <span class="classifier-delimiter">:</span> <span class="classifier">string, tool</span> <span class="classifier-delimiter">:</span> <span class="classifier">object)</span> <span class="classifier-delimiter">:</span> <span class="classifier">object</span></dt>
<dd><p class="first">Registers a custom tool that will become available on the Tools tool bar
of the Map Editor.</p>
<p>If a tool is already registered with the same <code class="docutils literal notranslate"><span class="pre">shortName</span></code> the existing
tool is replaced.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">tool</span></code> object has the following properties:</p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>name</strong> : string</td>
<td>Name of the tool as shown on the tool bar.</td>
</tr>
<tr class="row-even"><td><strong>map</strong> : <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a></td>
<td>Currently active tile map.</td>
</tr>
<tr class="row-odd"><td><strong>selectedTile</strong> : <a class="reference internal" href="#script-tile"><span class="std std-ref">Tile</span></a></td>
<td>The last clicked tile for the active map. See also the <code class="docutils literal notranslate"><span class="pre">currentBrush</span></code> property of <a class="reference internal" href="#script-mapeditor"><span class="std std-ref">MapEditor</span></a>.</td>
</tr>
<tr class="row-even"><td><strong>preview</strong> : <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a></td>
<td>Get or set the preview for tile layer edits.</td>
</tr>
<tr class="row-odd"><td><strong>tilePosition</strong> : <a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></td>
<td>Mouse cursor position in tile coordinates.</td>
</tr>
<tr class="row-even"><td><strong>statusInfo</strong> : string</td>
<td>Text shown in the status bar while the tool is active.</td>
</tr>
<tr class="row-odd"><td><strong>enabled</strong> : bool</td>
<td>Whether this tool is enabled.</td>
</tr>
<tr class="row-even"><td><strong>activated</strong> : function() : void</td>
<td>Called when the tool was activated.</td>
</tr>
<tr class="row-odd"><td><strong>deactivated</strong> : function() : void</td>
<td>Called when the tool was deactivated.</td>
</tr>
<tr class="row-even"><td><strong>keyPressed</strong> : function(key, modifiers) : void</td>
<td>Called when a key was pressed while the tool was active.</td>
</tr>
<tr class="row-odd"><td><strong>mouseEntered</strong> : function() : void</td>
<td>Called when the mouse entered the map view.</td>
</tr>
<tr class="row-even"><td><strong>mouseLeft</strong> : function() : void</td>
<td>Called when the mouse left the map view.</td>
</tr>
<tr class="row-odd"><td><strong>mouseMoved</strong> : function(x, y, modifiers) : void</td>
<td>Called when the mouse position in the map scene changed.</td>
</tr>
<tr class="row-even"><td><strong>mousePressed</strong> : function(button, x, y, modifiers) : void</td>
<td>Called when a mouse button was pressed.</td>
</tr>
<tr class="row-odd"><td><strong>mouseReleased</strong> : function(button, x, y, modifers) : void</td>
<td>Called when a mouse button was released.</td>
</tr>
<tr class="row-even"><td><strong>mouseDoubleClicked</strong> : function(button, x, y, modifiers) : void</td>
<td>Called when a mouse button was double-clicked.</td>
</tr>
<tr class="row-odd"><td><strong>modifiersChanged</strong> : function(modifiers) : void</td>
<td>Called when the active modifier keys changed.</td>
</tr>
<tr class="row-even"><td><strong>languageChanged</strong> : function() : void</td>
<td>Called when the language was changed.</td>
</tr>
<tr class="row-odd"><td><strong>mapChanged</strong> : function(oldMap : <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a>, newMap : <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a>) : void</td>
<td>Called when the active map was changed.</td>
</tr>
<tr class="row-even"><td><strong>tilePositionChanged</strong> : function() : void</td>
<td>Called when the hovered tile position changed.</td>
</tr>
<tr class="row-odd"><td><strong>updateStatusInfo</strong> : function() : void</td>
<td>Called when the hovered tile position changed. Used to override the default updating of the status bar text.</td>
</tr>
<tr class="row-even"><td><strong>updateEnabledState</strong> : function() : void</td>
<td>Called when the map or the current layer changed.</td>
</tr>
</tbody>
</table>
<p>Here is an example tool that places a rectangle each time the mouse has
moved by 32 pixels:</p>
<div class="code javascript last highlight-default notranslate"><div class="highlight"><pre><span></span>var tool = tiled.registerTool(&quot;PlaceRectangles&quot;, {
    name: &quot;Place Rectangles&quot;,

    mouseMoved: function(x, y, modifiers) {
        if (!this.pressed)
            return

        var dx = Math.abs(this.x - x)
        var dy = Math.abs(this.y - y)

        this.distance += Math.sqrt(dx*dx + dy*dy)
        this.x = x
        this.y = y

        if (this.distance &gt; 32) {
            var objectLayer = this.map.currentLayer

            if (objectLayer &amp;&amp; objectLayer.isObjectLayer) {
                var object = new MapObject(++this.counter)
                object.x = Math.min(this.lastX, x)
                object.y = Math.min(this.lastY, y)
                object.width = Math.abs(this.lastX - x)
                object.height = Math.abs(this.lastY - y)
                objectLayer.addObject(object)
            }

            this.distance = 0
            this.lastX = x
            this.lastY = y
        }
    },

    mousePressed: function(button, x, y, modifiers) {
        this.pressed = true
        this.x = x
        this.y = y
        this.distance = 0
        this.counter = 0
        this.lastX = x
        this.lastY = y
    },

    mouseReleased: function(button, x, y, modifiers) {
        this.pressed = false
    },
})
</pre></div>
</div>
</dd>
</dl>
<dl class="docutils" id="script-extendmenu">
<dt>tiled.extendMenu(id <span class="classifier-delimiter">:</span> <span class="classifier">string, items</span> <span class="classifier-delimiter">:</span> <span class="classifier">array | object)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Extends the menu with the given ID. Supports both a list of items or a
single item. Available menu IDs can be obtained using the <code class="docutils literal notranslate"><span class="pre">tiled.menus</span></code>
property.</p>
<p>A menu item is defined by an object with the following properties:</p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>action</strong> : string</td>
<td>ID of a registered action that the menu item will represent.</td>
</tr>
<tr class="row-even"><td><strong>before</strong> : string</td>
<td>ID of the action before which this menu item should be added (optional).</td>
</tr>
<tr class="row-odd"><td><strong>separator</strong> : bool</td>
<td>Set to <code class="docutils literal notranslate"><span class="pre">true</span></code> if this item is a menu separator (optional).</td>
</tr>
</tbody>
</table>
<p>If a menu item does not include a <code class="docutils literal notranslate"><span class="pre">before</span></code> property, the value is
inherited from the previous item. When this property is not set at all,
the items are appended to the end of the menu.</p>
<p>Example that adds a custom action to the “Edit” menu, before the “Select
All” action and separated by a separator:</p>
<div class="code javascript highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">tiled</span><span class="o">.</span><span class="n">extendMenu</span><span class="p">(</span><span class="s2">&quot;Edit&quot;</span><span class="p">,</span> <span class="p">[</span>
    <span class="p">{</span> <span class="n">action</span><span class="p">:</span> <span class="s2">&quot;CustomAction&quot;</span><span class="p">,</span> <span class="n">before</span><span class="p">:</span> <span class="s2">&quot;SelectAll&quot;</span> <span class="p">},</span>
    <span class="p">{</span> <span class="n">separator</span><span class="p">:</span> <span class="n">true</span> <span class="p">}</span>
<span class="p">]);</span>
</pre></div>
</div>
<p class="last">The “CustomAction” will need to have been registered before using
<a class="reference internal" href="#script-registeraction"><span class="std std-ref">tiled.registerAction()</span></a>.</p>
</dd>
</dl>
<dl class="docutils" id="script-tilesetformat">
<dt>tiled.tilesetFormat(shortName <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tilesetformatwrapper"><span class="std std-ref">TilesetFormat</span></a></span></dt>
<dd>Returns the tileset format object with the given name, or <cite>undefined</cite> if
no object was found. See the <cite>tilesetFormats</cite> property for more info.</dd>
</dl>
<dl class="docutils" id="script-tilesetformatforfile">
<dt>tiled.tilesetFormatForFile(fileName <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tilesetformatwrapper"><span class="std std-ref">TilesetFormat</span></a></span></dt>
<dd>Returns the tileset format object that can read the given file, or <cite>undefined</cite>
if no object was found.</dd>
</dl>
<dl class="docutils" id="script-mapformat">
<dt>tiled.mapFormat(shortName <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-mapformatwrapper"><span class="std std-ref">MapFormat</span></a></span></dt>
<dd>Returns the map format object with the given name, or <cite>undefined</cite> if no object
was found. See the <cite>mapFormats</cite> property for more info.</dd>
</dl>
<dl class="docutils" id="script-mapformatforfile">
<dt>tiled.mapFormatForFile(fileName <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-mapformatwrapper"><span class="std std-ref">MapFormat</span></a></span></dt>
<dd>Returns the map format object that can read the given file, or <cite>undefined</cite> if
no object was found.</dd>
</dl>
<dl class="docutils" id="script-tiled-filepath">
<dt>tiled.filePath(path <span class="classifier-delimiter">:</span> <span class="classifier">url)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-filepath"><span class="std std-ref">FilePath</span></a></span></dt>
<dd>Creates a <a class="reference internal" href="#script-filepath"><span class="std std-ref">FilePath</span></a> object with the given URL.</dd>
</dl>
<dl class="docutils" id="script-tiled-objectref">
<dt>tiled.objectRef(id <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-objectref"><span class="std std-ref">ObjectRef</span></a></span></dt>
<dd>Creates an <a class="reference internal" href="#script-objectref"><span class="std std-ref">ObjectRef</span></a> object with the given ID.</dd>
</dl>
</div>
<div class="section" id="signals">
<span id="script-tiled-signals"></span><h5>Signals<a class="headerlink" href="#signals" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>tiled.assetCreated(asset <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a>)</span></dt>
<dd>A new asset has been created.</dd>
<dt>tiled.assetOpened(asset <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a>)</span></dt>
<dd>An asset has been opened.</dd>
<dt>tiled.assetAboutToBeSaved(asset <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a>)</span></dt>
<dd>An asset is about to be saved. Can be used to make last-minute changes.</dd>
<dt>tiled.assetSaved(asset <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a>)</span></dt>
<dd>An asset has been saved.</dd>
<dt>tiled.assetAboutToBeClosed(asset <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a>)</span></dt>
<dd>An asset is about to be closed.</dd>
<dt>tiled.activeAssetChanged(asset <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a>)</span></dt>
<dd>The currently active asset has changed.</dd>
</dl>
</div>
</div>
<div class="section" id="action">
<span id="script-action"></span><h4>Action<a class="headerlink" href="#action" title="Permalink to this headline">¶</a></h4>
<p>An action that was registered with <a class="reference internal" href="#script-registeraction"><span class="std std-ref">tiled.registerAction()</span></a>.
This class is used to change the properties of the action. It can be added to a menu using
<a class="reference internal" href="#script-extendmenu"><span class="std std-ref">tiled.extendMenu()</span></a>.</p>
<div class="section" id="id1">
<h5>Properties<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>checkable</strong> : bool</td>
<td>Whether the action can be checked.</td>
</tr>
<tr class="row-even"><td><strong>checked</strong> : bool</td>
<td>Whether the action is checked.</td>
</tr>
<tr class="row-odd"><td><strong>enabled</strong> : bool</td>
<td>Whether the action is enabled.</td>
</tr>
<tr class="row-even"><td><strong>icon</strong> : string</td>
<td>File name of an icon.</td>
</tr>
<tr class="row-odd"><td><strong>iconVisibleInMenu</strong> : bool</td>
<td>Whether the action should show an icon in a menu.</td>
</tr>
<tr class="row-even"><td><strong>id</strong> : string <em>[read‑only]</em></td>
<td>The ID this action was registered with.</td>
</tr>
<tr class="row-odd"><td><strong>shortcut</strong> : QKeySequence</td>
<td>The shortcut (can be assigned a string like “Ctrl+K”).</td>
</tr>
<tr class="row-even"><td><strong>text</strong> : string</td>
<td>The text used when the action is part of a menu.</td>
</tr>
<tr class="row-odd"><td><strong>visible</strong> : bool</td>
<td>Whether the action is visible.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id2">
<h5>Functions<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>Action.trigger() <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Triggers the action.</dd>
<dt>Action.toggle() <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Changes the checked state to its opposite state.</dd>
</dl>
</div>
</div>
<div class="section" id="asset">
<span id="script-asset"></span><h4>Asset<a class="headerlink" href="#asset" title="Permalink to this headline">¶</a></h4>
<p>Inherits <a class="reference internal" href="#script-object"><span class="std std-ref">Object</span></a>.</p>
<p>Represents any top-level data type that can be saved to a file. Currently
either a <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a> or a <a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a>.</p>
<p>For assets that are loaded in the editor, all modifications and modifications
to their contained parts create undo commands. This includes both modifying
functions that are called as well as simply assigning to a writable property.</p>
<div class="section" id="id3">
<h5>Properties<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>fileName</strong> : string <em>[read‑only]</em></td>
<td>File name of the asset.</td>
</tr>
<tr class="row-even"><td><strong>modified</strong> : bool <em>[read‑only]</em></td>
<td>Whether the asset was modified after it was saved or loaded.</td>
</tr>
<tr class="row-odd"><td><strong>isTileMap</strong> : bool <em>[read‑only]</em></td>
<td>Whether the asset is a <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a>.</td>
</tr>
<tr class="row-even"><td><strong>isTileset</strong> : bool <em>[read‑only]</em></td>
<td>Whether the asset is a <a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id4">
<h5>Functions<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h5>
<dl class="docutils" id="script-asset-macro">
<dt>Asset.macro(text <span class="classifier-delimiter">:</span> <span class="classifier">string, callback</span> <span class="classifier-delimiter">:</span> <span class="classifier">function)</span> <span class="classifier-delimiter">:</span> <span class="classifier">value</span></dt>
<dd><p class="first">Creates a single undo command that wraps all changes applied to this asset
by the given callback. Recommended to avoid spamming the undo stack with
small steps that the user does not care about.</p>
<p>Example function that changes visibility of multiple layers in one step:</p>
<div class="code javascript highlight-default notranslate"><div class="highlight"><pre><span></span>tileMap.macro((visible ? &quot;Show&quot; : &quot;Hide&quot;) + &quot; Selected Layers&quot;, function() {
    tileMap.selectedLayers.forEach(function(layer) {
        layer.visible = visible
    })
})
</pre></div>
</div>
<p class="last">The returned value is whatever the callback function returned.</p>
</dd>
</dl>
<dl class="docutils" id="script-asset-undo">
<dt>Asset.undo() <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Undoes the last applied change. Note that the undo system is only enabled
for assets loaded in the editor!</dd>
</dl>
<dl class="docutils" id="script-asset-redo">
<dt>Asset.redo() <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Redoes the last change that was undone. Note that the undo system is only
enabled for assets loaded in the editor!</dd>
</dl>
</div>
</div>
<div class="section" id="fileformat">
<span id="script-fileformat"></span><h4>FileFormat<a class="headerlink" href="#fileformat" title="Permalink to this headline">¶</a></h4>
<p>Common functionality for file format readers and writers. (Since 1.4)</p>
<div class="section" id="id5">
<h5>Properties<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>canRead</strong> : bool <em>[read‑only]</em></td>
<td>Whether this format supports reading files.</td>
</tr>
<tr class="row-even"><td><strong>canWrite</strong> : bool <em>[read‑only]</em></td>
<td>Whether this format supports writing files.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id6">
<h5>Functions<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>FileFormat.supportsFile(fileName <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">bool</span></dt>
<dd>Returns whether the file is readable by this format.</dd>
</dl>
</div>
</div>
<div class="section" id="fileinfo">
<span id="script-fileinfo"></span><h4>FileInfo<a class="headerlink" href="#fileinfo" title="Permalink to this headline">¶</a></h4>
<p>Offers various operations on file paths, such as turning absolute paths into relative ones, splitting a path into its components, and so on.</p>
<div class="section" id="id7">
<h5>Functions<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>FileInfo.baseName(filePath <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Returns the file name of <code class="docutils literal notranslate"><span class="pre">filePath</span></code> up to (but not including) the first ‘.’ character.</dd>
<dt>FileInfo.canonicalPath(filePath <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd><p class="first">Returns a canonicalized <code class="docutils literal notranslate"><span class="pre">filePath</span></code>, i.e. an absolute path without symbolic links or redundant “.” or “..” elements. On Windows, drive substitutions are also resolved.</p>
<p class="last">It is recommended to use <code class="docutils literal notranslate"><span class="pre">canonicalPath</span></code> in only those cases where canonical paths are really necessary. In most cases, <code class="docutils literal notranslate"><span class="pre">cleanPath</span></code> should be enough.</p>
</dd>
<dt>FileInfo.cleanPath(filePath <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Returns <code class="docutils literal notranslate"><span class="pre">filePath</span></code> without redundant separators and with resolved occurrences of <cite>.</cite> and <cite>..</cite> components. For instance, <code class="docutils literal notranslate"><span class="pre">/usr/local//../bin/</span></code> becomes <code class="docutils literal notranslate"><span class="pre">/usr/bin</span></code>.</dd>
<dt>FileInfo.completeBaseName(filePath: string) <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Returns the file name of <code class="docutils literal notranslate"><span class="pre">filePath</span></code> up to (but not including) the last ‘.’ character.</dd>
<dt>FileInfo.completeSuffix(filePath <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Returns the file suffix of <code class="docutils literal notranslate"><span class="pre">filePath</span></code> from (but not including) the last ‘.’ character.</dd>
<dt>FileInfo.fileName(filePath <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Returns the last component of <code class="docutils literal notranslate"><span class="pre">filePath</span></code>, that is, everything after the last ‘/’ character.</dd>
<dt>FileInfo.fromNativeSeparators(filePath <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>On Windows, returns <code class="docutils literal notranslate"><span class="pre">filePath</span></code> with all ‘\’ characters replaced by ‘/’. On other operating systems, it returns the input unmodified.</dd>
<dt>FileInfo.isAbsolutePath(filePath <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">boolean</span></dt>
<dd>Returns true if <cite>filePath</cite> is an absolute path and false if it is a relative one.</dd>
<dt>FileInfo.joinPaths(…paths) <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Concatenates the given paths using the ‘/’ character.</dd>
<dt>FileInfo.path(filePath <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Returns the part of <code class="docutils literal notranslate"><span class="pre">filePath</span></code> that is not the file name, that is, everything up to (but not including) the last ‘/’ character. If <code class="docutils literal notranslate"><span class="pre">filePath</span></code> is just a file name, then ‘.’ is returned. If <code class="docutils literal notranslate"><span class="pre">filePath</span></code> ends with a ‘/’ character, then the file name is assumed to be empty for the purpose of the above definition.</dd>
<dt>FileInfo.relativePath(dirPath <span class="classifier-delimiter">:</span> <span class="classifier">string, filePath</span> <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Returns the path to <code class="docutils literal notranslate"><span class="pre">filePath</span></code> relative to the directory <code class="docutils literal notranslate"><span class="pre">dirPath</span></code>. If necessary, ‘..’ components are inserted.</dd>
<dt>FileInfo.suffix(filePath <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Returns the file suffix of <code class="docutils literal notranslate"><span class="pre">filePath</span></code> from (but not including) the first ‘.’ character.</dd>
<dt>FileInfo.toNativeSeparators(filePath <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>On Windows, returns <code class="docutils literal notranslate"><span class="pre">filePath</span></code> with all ‘/’ characters replaced by ‘\’. On other operating systems, it returns the input unmodified.</dd>
</dl>
</div>
</div>
<div class="section" id="grouplayer">
<span id="script-grouplayer"></span><h4>GroupLayer<a class="headerlink" href="#grouplayer" title="Permalink to this headline">¶</a></h4>
<p>Inherits <a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a>.</p>
<div class="section" id="id8">
<h5>Properties<a class="headerlink" href="#id8" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>layerCount</strong> : int <em>[read‑only]</em></td>
<td>Number of child layers the group layer has.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id9">
<h5>Functions<a class="headerlink" href="#id9" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>new GroupLayer([name <span class="classifier-delimiter">:</span> <span class="classifier">string])</span></dt>
<dd>Constructs a new group layer.</dd>
<dt>GroupLayer.layerAt(index <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a></span></dt>
<dd>Returns a reference to the child layer at the given index.</dd>
<dt>GroupLayer.removeLayerAt(index <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Removes the child layer at the given index. When a reference to the layer
still exists and this group layer isn’t already standalone, that reference
becomes a standalone copy of the layer.</dd>
<dt>GroupLayer.removeLayer(layer <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Removes the given layer from the group. If this group wasn’t standalone,
the reference to the layer becomes a standalone copy.</dd>
<dt>GroupLayer.insertLayerAt(index <span class="classifier-delimiter">:</span> <span class="classifier">int, layer</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Inserts the layer at the given index. The layer can’t already be part of
a map.</p>
<p class="last">When adding a <a class="reference internal" href="#script-tilelayer"><span class="std std-ref">TileLayer</span></a> to a map, the layer’s width and
height are automatically initialized to the size of the map (since Tiled 1.4.2).</p>
</dd>
<dt>GroupLayer.addLayer(layer <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Adds the layer to the group, above all existing layers. The layer can’t
already be part of a map.</p>
<p class="last">When adding a <a class="reference internal" href="#script-tilelayer"><span class="std std-ref">TileLayer</span></a> to a map, the layer’s width and
height are automatically initialized to the size of the map (since Tiled 1.4.2).</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="imagelayer">
<span id="script-imagelayer"></span><h4>ImageLayer<a class="headerlink" href="#imagelayer" title="Permalink to this headline">¶</a></h4>
<p>Inherits <a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a>.</p>
<div class="section" id="id10">
<h5>Properties<a class="headerlink" href="#id10" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>transparentColor</strong> : color</td>
<td>Color used as transparent color when rendering the image.</td>
</tr>
<tr class="row-even"><td><strong>imageSource</strong> : url</td>
<td>Reference to the image rendered by this layer.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="layer">
<span id="script-layer"></span><h4>Layer<a class="headerlink" href="#layer" title="Permalink to this headline">¶</a></h4>
<p>Inherits <a class="reference internal" href="#script-object"><span class="std std-ref">Object</span></a>.</p>
<div class="section" id="id11">
<h5>Properties<a class="headerlink" href="#id11" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>name</strong> : string</td>
<td>Name of the layer.</td>
</tr>
<tr class="row-even"><td><strong>opacity</strong> : number</td>
<td>Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).</td>
</tr>
<tr class="row-odd"><td><strong>visible</strong> : bool</td>
<td>Whether the layer is visible (affects child layer visibility for group layers).</td>
</tr>
<tr class="row-even"><td><strong>locked</strong> : bool</td>
<td>Whether the layer is locked (affects whether child layers are locked for group layers).</td>
</tr>
<tr class="row-odd"><td><strong>offset</strong> : <a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></td>
<td>Offset in pixels that is applied when this layer is rendered.</td>
</tr>
<tr class="row-even"><td><strong>map</strong> : <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a></td>
<td>Map that this layer is part of (or <code class="docutils literal notranslate"><span class="pre">null</span></code> in case of a standalone layer).</td>
</tr>
<tr class="row-odd"><td><strong>selected</strong> : bool</td>
<td>Whether the layer is selected.</td>
</tr>
<tr class="row-even"><td><strong>isTileLayer</strong> : bool <em>[read‑only]</em></td>
<td>Whether this layer is a <a class="reference internal" href="#script-tilelayer"><span class="std std-ref">TileLayer</span></a>.</td>
</tr>
<tr class="row-odd"><td><strong>isObjectLayer</strong> : bool <em>[read‑only]</em></td>
<td>Whether this layer is an <a class="reference internal" href="#script-objectgroup"><span class="std std-ref">ObjectGroup</span></a>.</td>
</tr>
<tr class="row-even"><td><strong>isGroupLayer</strong> : bool <em>[read‑only]</em></td>
<td>Whether this layer is a <a class="reference internal" href="#script-grouplayer"><span class="std std-ref">GroupLayer</span></a>.</td>
</tr>
<tr class="row-odd"><td><strong>isImageLayer</strong> : bool <em>[read‑only]</em></td>
<td>Whether this layer is an <a class="reference internal" href="#script-imagelayer"><span class="std std-ref">ImageLayer</span></a>.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="mapobject">
<span id="script-mapobject"></span><h4>MapObject<a class="headerlink" href="#mapobject" title="Permalink to this headline">¶</a></h4>
<p>Inherits <a class="reference internal" href="#script-object"><span class="std std-ref">Object</span></a>.</p>
<div class="section" id="id12">
<h5>Properties<a class="headerlink" href="#id12" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>id</strong> : int <em>[read‑only]</em></td>
<td>Unique (map-wide) ID of the object.</td>
</tr>
<tr class="row-even"><td><strong>shape</strong> : int</td>
<td><a class="reference internal" href="#script-mapobject-shape"><span class="std std-ref">Shape</span></a> of the object.</td>
</tr>
<tr class="row-odd"><td><strong>name</strong> : string</td>
<td>Name of the object.</td>
</tr>
<tr class="row-even"><td><strong>type</strong> : string</td>
<td>Type of the object.</td>
</tr>
<tr class="row-odd"><td><strong>x</strong> : number</td>
<td>X coordinate of the object in pixels.</td>
</tr>
<tr class="row-even"><td><strong>y</strong> : number</td>
<td>Y coordinate of the object in pixels.</td>
</tr>
<tr class="row-odd"><td><strong>pos</strong> : <a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></td>
<td>Position of the object in pixels.</td>
</tr>
<tr class="row-even"><td><strong>width</strong> : number</td>
<td>Width of the object in pixels.</td>
</tr>
<tr class="row-odd"><td><strong>height</strong> : number</td>
<td>Height of the object in pixels.</td>
</tr>
<tr class="row-even"><td><strong>size</strong> : <a class="reference internal" href="#script-size"><span class="std std-ref">size</span></a></td>
<td>Size of the object in pixels.</td>
</tr>
<tr class="row-odd"><td><strong>rotation</strong> : number</td>
<td>Rotation of the object in degrees clockwise.</td>
</tr>
<tr class="row-even"><td><strong>visible</strong> : bool</td>
<td>Whether the object is visible.</td>
</tr>
<tr class="row-odd"><td><strong>polygon</strong> : <a class="reference internal" href="#script-polygon"><span class="std std-ref">Polygon</span></a></td>
<td>Polygon of the object.</td>
</tr>
<tr class="row-even"><td><strong>text</strong> : string</td>
<td>The text of a text object.</td>
</tr>
<tr class="row-odd"><td><strong>font</strong> : <a class="reference internal" href="#script-font"><span class="std std-ref">Font</span></a></td>
<td>The font of a text object.</td>
</tr>
<tr class="row-even"><td><strong>textAlignment</strong> : <a class="reference internal" href="#script-alignment"><span class="std std-ref">Alignment</span></a></td>
<td>The alignment of a text object.</td>
</tr>
<tr class="row-odd"><td><strong>wordWrap</strong> : bool</td>
<td>Whether the text of a text object wraps based on the width of the object.</td>
</tr>
<tr class="row-even"><td><strong>textColor</strong> : color</td>
<td>Color of a text object.</td>
</tr>
<tr class="row-odd"><td><strong>tile</strong> : <a class="reference internal" href="#script-tile"><span class="std std-ref">Tile</span></a></td>
<td>Tile of the object.</td>
</tr>
<tr class="row-even"><td><strong>tileFlippedHorizontally</strong> : bool</td>
<td>Whether the tile is flipped horizontally.</td>
</tr>
<tr class="row-odd"><td><strong>tileFlippedVertically</strong> : bool</td>
<td>Whether the tile is flipped vertically.</td>
</tr>
<tr class="row-even"><td><strong>selected</strong> : bool</td>
<td>Whether the object is selected.</td>
</tr>
<tr class="row-odd"><td><strong>layer</strong> : <a class="reference internal" href="#script-objectgroup"><span class="std std-ref">ObjectGroup</span></a> <em>[read‑only]</em></td>
<td>Layer this object is part of (or <code class="docutils literal notranslate"><span class="pre">null</span></code> in case of a standalone object).</td>
</tr>
<tr class="row-even"><td><strong>map</strong> : <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a> <em>[read‑only]</em></td>
<td>Map this object is part of (or <code class="docutils literal notranslate"><span class="pre">null</span></code> in case of a standalone object).</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils" id="script-mapobject-shape">
<colgroup>
<col width="100%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">MapObject.Shape</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>MapObject.Rectangle</td>
</tr>
<tr class="row-odd"><td>MapObject.Polygon</td>
</tr>
<tr class="row-even"><td>MapObject.Polyline</td>
</tr>
<tr class="row-odd"><td>MapObject.Ellipse</td>
</tr>
<tr class="row-even"><td>MapObject.Text</td>
</tr>
<tr class="row-odd"><td>MapObject.Point</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id13">
<h5>Functions<a class="headerlink" href="#id13" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>new MapObject([name <span class="classifier-delimiter">:</span> <span class="classifier">string])</span></dt>
<dd>Constructs a new map object, which can be added to an <a class="reference internal" href="#script-objectgroup"><span class="std std-ref">ObjectGroup</span></a>.</dd>
</dl>
</div>
</div>
<div class="section" id="mapeditor">
<span id="script-mapeditor"></span><h4>MapEditor<a class="headerlink" href="#mapeditor" title="Permalink to this headline">¶</a></h4>
<div class="section" id="id14">
<h5>Properties<a class="headerlink" href="#id14" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>currentBrush</strong> : <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a></td>
<td>Get or set the currently used tile brush.</td>
</tr>
<tr class="row-even"><td><strong>currentMapView</strong> : <a class="reference internal" href="#script-mapview"><span class="std std-ref">MapView</span></a> <em>[read‑only]</em></td>
<td>Access the current map view.</td>
</tr>
<tr class="row-odd"><td><strong>tilesetsView</strong> : <a class="reference internal" href="#script-tilesetsview"><span class="std std-ref">TilesetsView</span></a> <em>[read‑only]</em></td>
<td>Access the Tilesets view.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="mapformat">
<span id="script-mapformatwrapper"></span><h4>MapFormat<a class="headerlink" href="#mapformat" title="Permalink to this headline">¶</a></h4>
<p>This is an object that can read or write map files. (Since 1.4)</p>
<p>Inherits <a class="reference internal" href="#script-fileformat"><span class="std std-ref">FileFormat</span></a>.</p>
<div class="section" id="id15">
<h5>Functions<a class="headerlink" href="#id15" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>MapFormat.read(fileName <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a></span></dt>
<dd>Read the given file as a map. This function will throw an error if reading
is not supported.</dd>
<dt>MapFormat.write(map <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a>, fileName</span> <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Write the given map to a file. This function will throw an error if writing
is not supported. If there is an error writing the file, it will return a
description of the error; otherwise, it will return “”.</dd>
</dl>
</div>
</div>
<div class="section" id="mapview">
<span id="script-mapview"></span><h4>MapView<a class="headerlink" href="#mapview" title="Permalink to this headline">¶</a></h4>
<p>The view displaying the map.</p>
<div class="section" id="id16">
<h5>Properties<a class="headerlink" href="#id16" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>scale</strong> : number</td>
<td>Get or set the scale of the view.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id17">
<h5>Functions<a class="headerlink" href="#id17" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>MapView.centerOn(x <span class="classifier-delimiter">:</span> <span class="classifier">number, y</span> <span class="classifier-delimiter">:</span> <span class="classifier">number)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Centers the view at the given location in screen coordinates.</dd>
</dl>
</div>
</div>
<div class="section" id="object">
<span id="script-object"></span><h4>Object<a class="headerlink" href="#object" title="Permalink to this headline">¶</a></h4>
<p>The base of most data types in Tiled. Provides the ability to associate custom
properties with the data.</p>
<div class="section" id="id18">
<h5>Properties<a class="headerlink" href="#id18" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>asset</strong> : <a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a> <em>[read‑only]</em></td>
<td>The asset this object is part of, or <code class="docutils literal notranslate"><span class="pre">null</span></code>.</td>
</tr>
<tr class="row-even"><td><strong>readOnly</strong> : bool <em>[read‑only]</em></td>
<td>Whether the object is read-only.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id19">
<h5>Functions<a class="headerlink" href="#id19" title="Permalink to this headline">¶</a></h5>
<dl class="docutils" id="script-object-property">
<dt>Object.property(name <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">variant</span></dt>
<dd><p class="first">Returns the value of the custom property with the given name, or
<code class="docutils literal notranslate"><span class="pre">undefined</span></code> if no such property is set on the object. Does not include
inherited values (see <a class="reference internal" href="#script-object-resolvedproperty"><span class="std std-ref">resolvedProperty</span></a>).</p>
<p><code class="docutils literal notranslate"><span class="pre">file</span></code> properties are returned as <a class="reference internal" href="#script-filepath"><span class="std std-ref">FilePath</span></a>.</p>
<p class="last"><code class="docutils literal notranslate"><span class="pre">object</span></code> properties are returned as <a class="reference internal" href="#script-mapobject"><span class="std std-ref">MapObject</span></a> when possible,
or <a class="reference internal" href="#script-objectref"><span class="std std-ref">ObjectRef</span></a> when the object could not be found.</p>
</dd>
</dl>
<dl class="docutils" id="script-object-setproperty">
<dt>Object.setProperty(name <span class="classifier-delimiter">:</span> <span class="classifier">string, value</span> <span class="classifier-delimiter">:</span> <span class="classifier">variant)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Sets the value of the custom property with the given name. Supported types
are <code class="docutils literal notranslate"><span class="pre">bool</span></code>, <code class="docutils literal notranslate"><span class="pre">number</span></code>, <code class="docutils literal notranslate"><span class="pre">string</span></code>, <a class="reference internal" href="#script-filepath"><span class="std std-ref">FilePath</span></a>,
<a class="reference internal" href="#script-objectref"><span class="std std-ref">ObjectRef</span></a> and <a class="reference internal" href="#script-mapobject"><span class="std std-ref">MapObject</span></a>.</p>
<p>When setting a <code class="docutils literal notranslate"><span class="pre">number</span></code>, the property type will be set to either <code class="docutils literal notranslate"><span class="pre">int</span></code>
or <code class="docutils literal notranslate"><span class="pre">float</span></code>, depending on whether it is a whole number.</p>
<p class="last"><em>Note:</em> Support for setting <code class="docutils literal notranslate"><span class="pre">color</span></code> properties is currently missing.</p>
</dd>
</dl>
<dl class="docutils" id="script-object-properties">
<dt>Object.properties() <span class="classifier-delimiter">:</span> <span class="classifier">object</span></dt>
<dd>Returns all custom properties set on this object. Modifications to the
properties will not affect the original object. Does not include inherited
values (see <a class="reference internal" href="#script-object-resolvedproperties"><span class="std std-ref">resolvedProperties</span></a>).</dd>
</dl>
<dl class="docutils" id="script-object-setproperties">
<dt>Object.setProperties(properties <span class="classifier-delimiter">:</span> <span class="classifier">object)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Replaces all currently set custom properties with a new set of properties.</dd>
</dl>
<dl class="docutils" id="script-object-removeproperty">
<dt>Object.removeProperty(name <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Removes the custom property with the given name.</dd>
</dl>
<dl class="docutils" id="script-object-resolvedproperty">
<dt>Object.resolvedProperty(name <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">variant</span></dt>
<dd>Returns the value of the custom property with the given name, or
<code class="docutils literal notranslate"><span class="pre">undefined</span></code> if no such property is set. Includes values inherited from
object types, templates and tiles where applicable.</dd>
</dl>
<dl class="docutils" id="script-object-resolvedproperties">
<dt>Object.resolvedProperties() <span class="classifier-delimiter">:</span> <span class="classifier">object</span></dt>
<dd>Returns all custom properties set on this object. Modifications to the
properties will not affect the original object. Includes values inherited from
object types, templates and tiles where applicable.</dd>
</dl>
</div>
</div>
<div class="section" id="objectgroup">
<span id="script-objectgroup"></span><h4>ObjectGroup<a class="headerlink" href="#objectgroup" title="Permalink to this headline">¶</a></h4>
<p>Inherits <a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a>.</p>
<p>The “ObjectGroup” is a type of layer that can contain objects. It will
henceforth be referred to as a layer.</p>
<div class="section" id="id20">
<h5>Properties<a class="headerlink" href="#id20" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>objects</strong> : [<a class="reference internal" href="#script-mapobject"><span class="std std-ref">MapObject</span></a>] <em>[read‑only]</em></td>
<td>Array of all objects on this layer.</td>
</tr>
<tr class="row-even"><td><strong>objectCount</strong> : int <em>[read‑only]</em></td>
<td>Number of objects on this layer.</td>
</tr>
<tr class="row-odd"><td><strong>color</strong> : color</td>
<td>Color of shape and point objects on this layer (when not set by object type).</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id21">
<h5>Functions<a class="headerlink" href="#id21" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>new ObjectGroup([name <span class="classifier-delimiter">:</span> <span class="classifier">string])</span></dt>
<dd>Constructs a new object layer, which can be added to a <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a>.</dd>
<dt>ObjectGroup.objectAt(index <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-mapobject"><span class="std std-ref">MapObject</span></a></span></dt>
<dd>Returns a reference to the object at the given index. When the object is
removed, the reference turns into a standalone copy of the object.</dd>
<dt>ObjectGroup.removeObjectAt(index <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Removes the object at the given index.</dd>
<dt>ObjectGroup.removeObject(object <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-mapobject"><span class="std std-ref">MapObject</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Removes the given object from this layer. The object reference turns into
a standalone copy of the object.</dd>
<dt>ObjectGroup.insertObjectAt(index <span class="classifier-delimiter">:</span> <span class="classifier">int, object</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-mapobject"><span class="std std-ref">MapObject</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Inserts the object at the given index. The object can’t already be part
of a layer.</dd>
<dt>ObjectGroup.addObject(object <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-mapobject"><span class="std std-ref">MapObject</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Adds the given object to the layer. The object can’t already be part of
a layer.</dd>
</dl>
</div>
</div>
<div class="section" id="selectedarea">
<span id="script-selectedarea"></span><h4>SelectedArea<a class="headerlink" href="#selectedarea" title="Permalink to this headline">¶</a></h4>
<div class="section" id="id22">
<h5>Properties<a class="headerlink" href="#id22" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>boundingRect</strong> : <a class="reference internal" href="#script-rect"><span class="std std-ref">rect</span></a> <em>[read‑only]</em></td>
<td>Bounding rectangle of the selected area.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id23">
<h5>Functions<a class="headerlink" href="#id23" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>SelectedArea.get() <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-region"><span class="std std-ref">region</span></a></span></dt>
<dd>Returns the selected region.</dd>
<dt>SelectedArea.set(rect <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-rect"><span class="std std-ref">rect</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Sets the selected area to the given rectangle.</dd>
<dt>SelectedArea.set(region <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-region"><span class="std std-ref">region</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Sets the selected area to the given region.</dd>
<dt>SelectedArea.add(rect <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-rect"><span class="std std-ref">rect</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Adds the given rectangle to the selected area.</dd>
<dt>SelectedArea.add(region <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-region"><span class="std std-ref">region</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Adds the given region to the selected area.</dd>
<dt>SelectedArea.subtract(rect <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-rect"><span class="std std-ref">rect</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Subtracts the given rectangle from the selected area.</dd>
<dt>SelectedArea.subtract(region <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-region"><span class="std std-ref">region</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Subtracts the given region from the selected area.</dd>
<dt>SelectedArea.intersect(rect <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-rect"><span class="std std-ref">rect</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Sets the selected area to the intersection of the current selected area and the given rectangle.</dd>
<dt>SelectedArea.intersect(region <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-region"><span class="std std-ref">region</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Sets the selected area to the intersection of the current selected area and the given region.</dd>
</dl>
</div>
</div>
<div class="section" id="terrain">
<span id="script-terrain"></span><h4>Terrain<a class="headerlink" href="#terrain" title="Permalink to this headline">¶</a></h4>
<p>Inherits <a class="reference internal" href="#script-object"><span class="std std-ref">Object</span></a>.</p>
<div class="section" id="id24">
<h5>Properties<a class="headerlink" href="#id24" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>id</strong> : int <em>[read‑only]</em></td>
<td>ID of this terrain.</td>
</tr>
<tr class="row-even"><td><strong>name</strong> : string</td>
<td>Name of the terrain.</td>
</tr>
<tr class="row-odd"><td><strong>imageTile</strong> : <a class="reference internal" href="#script-tile"><span class="std std-ref">Tile</span></a></td>
<td>The tile representing the terrain (needs to be from the same tileset).</td>
</tr>
<tr class="row-even"><td><strong>tileset</strong> : <a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a> <em>[read‑only]</em></td>
<td>The tileset of the terrain.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="tile">
<span id="script-tile"></span><h4>Tile<a class="headerlink" href="#tile" title="Permalink to this headline">¶</a></h4>
<p>Inherits <a class="reference internal" href="#script-object"><span class="std std-ref">Object</span></a>.</p>
<div class="section" id="id25">
<h5>Properties<a class="headerlink" href="#id25" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>id</strong> : int <em>[read‑only]</em></td>
<td>ID of this tile within its tileset.</td>
</tr>
<tr class="row-even"><td><strong>width</strong> : int <em>[read‑only]</em></td>
<td>Width of the tile in pixels.</td>
</tr>
<tr class="row-odd"><td><strong>height</strong> : int <em>[read‑only]</em></td>
<td>Height of the tile in pixels.</td>
</tr>
<tr class="row-even"><td><strong>size</strong> : <a class="reference internal" href="#script-size"><span class="std std-ref">size</span></a> <em>[read‑only]</em></td>
<td>Size of the tile in pixels.</td>
</tr>
<tr class="row-odd"><td><strong>type</strong> : string</td>
<td>Type of the tile.</td>
</tr>
<tr class="row-even"><td><strong>imageFileName</strong> : string</td>
<td>File name of the tile image (when the tile is part of an image collection tileset).</td>
</tr>
<tr class="row-odd"><td><strong>terrain</strong> : <a class="reference internal" href="#script-tileterrains"><span class="std std-ref">Terrains</span></a></td>
<td>An object specifying the terrain at each corner of the tile.</td>
</tr>
<tr class="row-even"><td><strong>probability</strong> : number</td>
<td>Probability that the tile gets chosen relative to other tiles.</td>
</tr>
<tr class="row-odd"><td><strong>objectGroup</strong> : <a class="reference internal" href="#script-objectgroup"><span class="std std-ref">ObjectGroup</span></a></td>
<td>The <a class="reference internal" href="#script-objectgroup"><span class="std std-ref">ObjectGroup</span></a> associated with the tile in case collision shapes were defined. Returns <code class="docutils literal notranslate"><span class="pre">null</span></code> if no collision shapes were defined for this tile.</td>
</tr>
<tr class="row-even"><td><strong>frames</strong> : <a class="reference internal" href="#script-frames"><span class="std std-ref">[frame]</span></a></td>
<td>This tile’s animation as an array of frames.</td>
</tr>
<tr class="row-odd"><td><strong>animated</strong> : bool <em>[read‑only]</em></td>
<td>Indicates whether this tile is animated.</td>
</tr>
<tr class="row-even"><td><strong>tileset</strong> : <a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a> <em>[read‑only]</em></td>
<td>The tileset of the tile.</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils" id="script-tile-flags">
<colgroup>
<col width="100%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Tile.Flags</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Tile.FlippedHorizontally</td>
</tr>
<tr class="row-odd"><td>Tile.FlippedVertically</td>
</tr>
<tr class="row-even"><td>Tile.FlippedAntiDiagonally</td>
</tr>
<tr class="row-odd"><td>Tile.RotatedHexagonal120</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils" id="script-tile-corner">
<colgroup>
<col width="100%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Tile.Corner</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Tile.TopLeft</td>
</tr>
<tr class="row-odd"><td>Tile.TopRight</td>
</tr>
<tr class="row-even"><td>Tile.BottomLeft</td>
</tr>
<tr class="row-odd"><td>Tile.BottomRight</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id26">
<h5>Functions<a class="headerlink" href="#id26" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>Tile.terrainAtCorner(corner <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tile-corner"><span class="std std-ref">Corner</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-terrain"><span class="std std-ref">Terrain</span></a></span></dt>
<dd>Returns the terrain used at the given corner.</dd>
<dt>Tile.setTerrainAtCorner(corner <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tile-corner"><span class="std std-ref">Corner</span></a>, <a class="reference internal" href="#script-terrain"><span class="std std-ref">Terrain</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Sets the terrain used at the given corner.</p>
<p>As an example, suppose you had a sand terrain added to your tileset, here’s how you could apply it to the top-left corner of the first 10 tiles in the tileset:</p>
<div class="code javascript last highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">var</span> <span class="n">tileset</span> <span class="o">=</span> <span class="n">tiled</span><span class="o">.</span><span class="n">activeAsset</span>
<span class="n">var</span> <span class="n">sand</span> <span class="o">=</span> <span class="n">tileset</span><span class="o">.</span><span class="n">terrains</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">tileset</span><span class="o">.</span><span class="n">macro</span><span class="p">(</span><span class="s2">&quot;Change Terrain&quot;</span><span class="p">,</span> <span class="n">function</span><span class="p">()</span> <span class="p">{</span>
   <span class="k">for</span> <span class="p">(</span><span class="n">let</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="mi">10</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span>
      <span class="n">tileset</span><span class="o">.</span><span class="n">tiles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">setTerrainAtCorner</span><span class="p">(</span><span class="n">Tile</span><span class="o">.</span><span class="n">TopLeft</span><span class="p">,</span> <span class="n">sand</span><span class="p">);</span>
<span class="p">})</span>
</pre></div>
</div>
</dd>
</dl>
</div>
</div>
<div class="section" id="tilecollisioneditor">
<span id="script-tilecollisioneditor"></span><h4>TileCollisionEditor<a class="headerlink" href="#tilecollisioneditor" title="Permalink to this headline">¶</a></h4>
<div class="section" id="id27">
<h5>Properties<a class="headerlink" href="#id27" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>selectedObjects</strong> : [<a class="reference internal" href="#script-mapobject"><span class="std std-ref">MapObject</span></a>]</td>
<td>Selected objects.</td>
</tr>
<tr class="row-even"><td><strong>view</strong> : [<a class="reference internal" href="#script-mapview"><span class="std std-ref">MapView</span></a>]</td>
<td>The map view used by the Collision Editor.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id28">
<h5>Functions<a class="headerlink" href="#id28" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>TileCollisionEditor.focusObject(object <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-mapobject"><span class="std std-ref">MapObject</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Focuses the given object in the collision editor view and makes sure its
visible in its objects list. Does not automatically select the object.</dd>
</dl>
</div>
</div>
<div class="section" id="tilelayer">
<span id="script-tilelayer"></span><h4>TileLayer<a class="headerlink" href="#tilelayer" title="Permalink to this headline">¶</a></h4>
<p>Inherits <a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a>.</p>
<p>Note that while tile layers have a size, the size is generally ignored on
infinite maps. Even for fixed size maps, nothing in the scripting API stops you
from changing the layer outside of its boundaries and changing the size of the
layer has no effect on its contents. If you want to change the size while
affecting the contents, use the <code class="docutils literal notranslate"><span class="pre">resize</span></code> function.</p>
<div class="section" id="id29">
<h5>Properties<a class="headerlink" href="#id29" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>width</strong> : int</td>
<td>Width of the layer in tiles (only relevant for non-infinite maps).</td>
</tr>
<tr class="row-even"><td><strong>height</strong> : int</td>
<td>Height of the layer in tiles (only relevant for non-infinite maps).</td>
</tr>
<tr class="row-odd"><td><strong>size</strong> : <a class="reference internal" href="#script-size"><span class="std std-ref">size</span></a></td>
<td>Size of the layer in tiles (has <code class="docutils literal notranslate"><span class="pre">width</span></code> and <code class="docutils literal notranslate"><span class="pre">height</span></code> members) (only relevant for non-infinite maps).</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id30">
<h5>Functions<a class="headerlink" href="#id30" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>new TileLayer([name <span class="classifier-delimiter">:</span> <span class="classifier">string])</span></dt>
<dd>Constructs a new tile layer, which can be added to a <a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a>.</dd>
<dt>TileLayer.region() <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-region"><span class="std std-ref">region</span></a></span></dt>
<dd>Returns the region of the layer that is covered with tiles.</dd>
<dt>TileLayer.resize(size <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-size"><span class="std std-ref">size</span></a>, offset</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Resizes the layer, erasing the part of the contents that falls outside of
the layer’s new size. The offset parameter can be used to shift the contents
by a certain distance in tiles before applying the resize.</dd>
<dt>TileLayer.cellAt(x <span class="classifier-delimiter">:</span> <span class="classifier">int, y</span> <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-cell"><span class="std std-ref">cell</span></a></span></dt>
<dd>Returns the value of the cell at the given position. Can be used to query
the flags and the tile ID, but does not currently allow getting a tile
reference.</dd>
<dt>TileLayer.flagsAt(x <span class="classifier-delimiter">:</span> <span class="classifier">int, y</span> <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
<dd>Returns the <a class="reference internal" href="#script-tile-flags"><span class="std std-ref">flags</span></a> used for the tile at the given
position.</dd>
<dt>TileLayer.tileAt(x <span class="classifier-delimiter">:</span> <span class="classifier">int, y</span> <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tile"><span class="std std-ref">Tile</span></a></span></dt>
<dd>Returns the tile used at the given position, or <code class="docutils literal notranslate"><span class="pre">null</span></code> for empty spaces.</dd>
</dl>
<dl class="docutils" id="script-tilelayer-edit">
<dt>TileLayer.edit() <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tilelayeredit"><span class="std std-ref">TileLayerEdit</span></a></span></dt>
<dd>Returns an object that enables making modifications to the tile layer.</dd>
</dl>
</div>
</div>
<div class="section" id="tilelayeredit">
<span id="script-tilelayeredit"></span><h4>TileLayerEdit<a class="headerlink" href="#tilelayeredit" title="Permalink to this headline">¶</a></h4>
<p>This object enables modifying the tiles on a tile layer. Tile layers can’t be
modified directly for reasons of efficiency. The <a class="reference internal" href="#script-tilelayeredit-apply"><span class="std std-ref">apply()</span></a>
function needs to be called when you’re done making changes.</p>
<p>An instance of this object is created by calling <a class="reference internal" href="#script-tilelayer-edit"><span class="std std-ref">TileLayer.edit()</span></a>.</p>
<div class="section" id="id31">
<h5>Properties<a class="headerlink" href="#id31" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>target</strong> : <a class="reference internal" href="#script-tilelayer"><span class="std std-ref">TileLayer</span></a> <em>[read‑only]</em></td>
<td>The target layer of this edit object.</td>
</tr>
<tr class="row-even"><td><strong>mergeable</strong> : bool</td>
<td>Whether applied edits are mergeable with previous edits. Starts out as <code class="docutils literal notranslate"><span class="pre">false</span></code> and is automatically set to <code class="docutils literal notranslate"><span class="pre">true</span></code> by <a class="reference internal" href="#script-tilelayeredit-apply"><span class="std std-ref">apply()</span></a>.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id32">
<h5>Functions<a class="headerlink" href="#id32" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>TileLayerEdit.setTile(x <span class="classifier-delimiter">:</span> <span class="classifier">int, y</span> <span class="classifier-delimiter">:</span> <span class="classifier">int, tile</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tile"><span class="std std-ref">Tile</span></a> [, flags</span> <span class="classifier-delimiter">:</span> <span class="classifier">int = 0])</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Sets the tile at the given location, optionally specifying <a class="reference internal" href="#script-tile-flags"><span class="std std-ref">tile flags</span></a>.</dd>
</dl>
<dl class="docutils" id="script-tilelayeredit-apply">
<dt>TileLayerEdit.apply() <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Applies all changes made through this object. This object can be reused to
make further changes.</dd>
</dl>
</div>
</div>
<div class="section" id="tilemap">
<span id="script-map"></span><h4>TileMap<a class="headerlink" href="#tilemap" title="Permalink to this headline">¶</a></h4>
<p>Inherits <a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a>.</p>
<div class="section" id="id33">
<h5>Properties<a class="headerlink" href="#id33" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>width</strong> : int</td>
<td>Width of the map in tiles (only relevant for non-infinite maps).</td>
</tr>
<tr class="row-even"><td><strong>height</strong> : int</td>
<td>Height of the map in tiles (only relevant for non-infinite maps).</td>
</tr>
<tr class="row-odd"><td><strong>size</strong> : <a class="reference internal" href="#script-size"><span class="std std-ref">size</span></a> <em>[read‑only]</em></td>
<td>Size of the map in tiles (only relevant for non-infinite maps).</td>
</tr>
<tr class="row-even"><td><strong>tileWidth</strong> : int</td>
<td>Tile width (used by tile layers).</td>
</tr>
<tr class="row-odd"><td><strong>tileHeight</strong> : int</td>
<td>Tile height (used by tile layers).</td>
</tr>
<tr class="row-even"><td><strong>infinite</strong> : bool</td>
<td>Whether this map is infinite.</td>
</tr>
<tr class="row-odd"><td><strong>hexSideLength</strong> : int</td>
<td>Length of the side of a hexagonal tile (used by tile layers on hexagonal maps).</td>
</tr>
<tr class="row-even"><td><strong>staggerAxis</strong> : <a class="reference internal" href="#script-map-staggeraxis"><span class="std std-ref">StaggerAxis</span></a></td>
<td>For staggered and hexagonal maps, determines which axis (X or Y) is staggered.</td>
</tr>
<tr class="row-odd"><td><strong>orientation</strong> : <a class="reference internal" href="#script-map-orientation"><span class="std std-ref">Orientation</span></a></td>
<td>General map orientation</td>
</tr>
<tr class="row-even"><td><strong>renderOrder</strong> : <a class="reference internal" href="#script-map-renderorder"><span class="std std-ref">RenderOrder</span></a></td>
<td>Tile rendering order (only implemented for orthogonal maps)</td>
</tr>
<tr class="row-odd"><td><strong>staggerIndex</strong> : <a class="reference internal" href="#script-map-staggerindex"><span class="std std-ref">StaggerIndex</span></a></td>
<td>For staggered and hexagonal maps, determines whether the even or odd indexes along the staggered axis are shifted.</td>
</tr>
<tr class="row-even"><td><strong>backgroundColor</strong> : color</td>
<td>Background color of the map.</td>
</tr>
<tr class="row-odd"><td><strong>layerDataFormat</strong> : <a class="reference internal" href="#script-map-layerdataformat"><span class="std std-ref">LayerDataFormat</span></a></td>
<td>The format in which the layer data is stored, taken into account by TMX, JSON and Lua map formats.</td>
</tr>
<tr class="row-even"><td><strong>layerCount</strong> : int <em>[read‑only]</em></td>
<td>Number of top-level layers the map has.</td>
</tr>
<tr class="row-odd"><td><strong>tilesets</strong> : [<a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a>]</td>
<td>The list of tilesets referenced by this map. To determine which tilesets are actually used, call <a class="reference internal" href="#script-map-usedtilesets"><span class="std std-ref">usedTilesets()</span></a>.</td>
</tr>
<tr class="row-even"><td><strong>selectedArea</strong> : <a class="reference internal" href="#script-selectedarea"><span class="std std-ref">SelectionArea</span></a></td>
<td>The selected area of tiles.</td>
</tr>
<tr class="row-odd"><td><strong>currentLayer</strong> : <a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a></td>
<td>The current layer.</td>
</tr>
<tr class="row-even"><td><strong>selectedLayers</strong> : [<a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a>]</td>
<td>Selected layers.</td>
</tr>
<tr class="row-odd"><td><strong>selectedObjects</strong> : [<a class="reference internal" href="#script-mapobject"><span class="std std-ref">MapObject</span></a>]</td>
<td>Selected objects.</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils" id="script-map-orientation">
<colgroup>
<col width="100%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">TileMap.Orientation</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>TileMap.Unknown</td>
</tr>
<tr class="row-odd"><td>TileMap.Orthogonal</td>
</tr>
<tr class="row-even"><td>TileMap.Isometric</td>
</tr>
<tr class="row-odd"><td>TileMap.Staggered</td>
</tr>
<tr class="row-even"><td>TileMap.Hexagonal</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils" id="script-map-layerdataformat">
<colgroup>
<col width="100%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">TileMap.LayerDataFormat</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>TileMap.XML</td>
</tr>
<tr class="row-odd"><td>TileMap.Base64</td>
</tr>
<tr class="row-even"><td>TileMap.Base64Gzip</td>
</tr>
<tr class="row-odd"><td>TileMap.Base64Zlib</td>
</tr>
<tr class="row-even"><td>TileMap.Base64Zstandard</td>
</tr>
<tr class="row-odd"><td>TileMap.CSV</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils" id="script-map-renderorder">
<colgroup>
<col width="100%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">TileMap.RenderOrder</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>TileMap.RightDown</td>
</tr>
<tr class="row-odd"><td>TileMap.RightUp</td>
</tr>
<tr class="row-even"><td>TileMap.LeftDown</td>
</tr>
<tr class="row-odd"><td>TileMap.LeftUp</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils" id="script-map-staggeraxis">
<colgroup>
<col width="100%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">TileMap.StaggerAxis</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>TileMap.StaggerX</td>
</tr>
<tr class="row-odd"><td>TileMap.StaggerY</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils" id="script-map-staggerindex">
<colgroup>
<col width="100%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">TileMap.StaggerIndex</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>TileMap.StaggerOdd</td>
</tr>
<tr class="row-odd"><td>TileMap.StaggerEven</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id34">
<h5>Functions<a class="headerlink" href="#id34" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>new TileMap()</dt>
<dd>Constructs a new map.</dd>
</dl>
<dl class="docutils" id="script-map-automap">
<dt>TileMap.autoMap([rulesFile <span class="classifier-delimiter">:</span> <span class="classifier">string])</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Applies <a class="reference internal" href="index.html#document-manual/automapping"><span class="doc">Automapping</span></a> using the given rules file, or using the
default rules file is none is given.</p>
<p class="last"><em>This operation can only be applied to maps loaded from a file.</em></p>
</dd>
<dt>TileMap.autoMap(region <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-region"><span class="std std-ref">region</span></a> | <a class="reference internal" href="#script-rect"><span class="std std-ref">rect</span></a> [, rulesFile</span> <span class="classifier-delimiter">:</span> <span class="classifier">string])</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Applies <a class="reference internal" href="index.html#document-manual/automapping"><span class="doc">Automapping</span></a> in the given region using the given
rules file, or using the default rules file is none is given.</p>
<p class="last"><em>This operation can only be applied to maps loaded from a file.</em></p>
</dd>
</dl>
<dl class="docutils" id="script-map-setsize">
<dt>TileMap.setSize(width <span class="classifier-delimiter">:</span> <span class="classifier">int, height</span> <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Sets the size of the map in tiles. This does not affect the contents of the map.</p>
<p class="last">See also <a class="reference internal" href="#script-map-resize"><span class="std std-ref">resize</span></a>.</p>
</dd>
</dl>
<dl class="docutils" id="script-map-settilesize">
<dt>TileMap.setTileSize(width <span class="classifier-delimiter">:</span> <span class="classifier">int, height</span> <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Sets the tile size of the map in pixels. This affects the rendering of all tile layers.</dd>
</dl>
<dl class="docutils" id="script-map-layerat">
<dt>TileMap.layerAt(index <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a></span></dt>
<dd>Returns a reference to the top-level layer at the given index. When the
layer gets removed from the map, the reference changes to a standalone
copy of the layer.</dd>
</dl>
<dl class="docutils" id="script-map-removelayerat">
<dt>TileMap.removeLayerAt(index <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Removes the top-level layer at the given index. When a reference to the
layer still exists, that reference becomes a standalone copy of the layer.</dd>
</dl>
<dl class="docutils" id="script-map-removelayer">
<dt>TileMap.removeLayer(layer <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Removes the given layer from the map. The reference to the layer becomes
a standalone copy.</dd>
</dl>
<dl class="docutils" id="script-map-insertlayerat">
<dt>TileMap.insertLayerAt(index <span class="classifier-delimiter">:</span> <span class="classifier">int, layer</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Inserts the layer at the given index. The layer can’t already be part of
a map.</dd>
</dl>
<dl class="docutils" id="script-map-addlayer">
<dt>TileMap.addLayer(layer <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-layer"><span class="std std-ref">Layer</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Adds the layer to the map, above all existing layers. The layer can’t
already be part of a map.</dd>
</dl>
<dl class="docutils" id="script-map-addtileset">
<dt>TileMap.addTileset(tileset <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">bool</span></dt>
<dd>Adds the given tileset to the list of tilesets referenced by this map.
Returns <code class="docutils literal notranslate"><span class="pre">true</span></code> if the tileset was added, or <code class="docutils literal notranslate"><span class="pre">false</span></code> if the tileset was
already referenced by this map.</dd>
</dl>
<dl class="docutils" id="script-map-replacetileset">
<dt>TileMap.replaceTileset(oldTileset <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a>, newTileset</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">bool</span></dt>
<dd>Replaces all occurrences of <code class="docutils literal notranslate"><span class="pre">oldTileset</span></code> with <code class="docutils literal notranslate"><span class="pre">newTileset</span></code>. Returns
<code class="docutils literal notranslate"><span class="pre">true</span></code> on success, or <code class="docutils literal notranslate"><span class="pre">false</span></code> when either the old tileset was not
referenced by the map, or when the new tileset was already referenced by
the map.</dd>
</dl>
<dl class="docutils" id="script-map-removetileset">
<dt>TileMap.removeTileset(tileset <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier">bool</span></dt>
<dd>Removes the given tileset from the list of tilesets referenced by this
map. Returns <code class="docutils literal notranslate"><span class="pre">true</span></code> on success, or <code class="docutils literal notranslate"><span class="pre">false</span></code> when the given tileset was
not referenced by this map or when the tileset was still in use by a tile
layer or tile object.</dd>
</dl>
<dl class="docutils" id="script-map-usedtilesets">
<dt>TileMap.usedTilesets() <span class="classifier-delimiter">:</span> <span class="classifier">[<a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a>]</span></dt>
<dd>Returns the list of tilesets actually used by this map. This is generally
a subset of the tilesets referenced by the map (the <code class="docutils literal notranslate"><span class="pre">TileMap.tilesets</span></code>
property).</dd>
</dl>
<dl class="docutils" id="script-map-merge">
<dt>TileMap.merge(map <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-map"><span class="std std-ref">TileMap</span></a> [, canJoin</span> <span class="classifier-delimiter">:</span> <span class="classifier">bool = false])</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Merges the tile layers in the given map with this one. If only a single
tile layer exists in the given map, it will be merged with the
<code class="docutils literal notranslate"><span class="pre">currentLayer</span></code>.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">canJoin</span></code> is <code class="docutils literal notranslate"><span class="pre">true</span></code>, the operation joins with the previous one on
the undo stack when possible. Useful for reducing the amount of undo
commands.</p>
<p class="last"><em>This operation can currently only be applied to maps loaded from a file.</em></p>
</dd>
</dl>
<dl class="docutils" id="script-map-resize">
<dt>TileMap.resize(size <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-size"><span class="std std-ref">size</span></a> [, offset</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a> [, removeObjects</span> <span class="classifier-delimiter">:</span> <span class="classifier">bool = false]])</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd><p class="first">Resizes the map to the given size, optionally applying an offset (in tiles).</p>
<p><em>This operation can currently only be applied to maps loaded from a file.</em></p>
<p class="last">See also <a class="reference internal" href="#script-map-setsize"><span class="std std-ref">setSize</span></a>.</p>
</dd>
</dl>
<dl class="docutils" id="script-map-screentotile">
<dt>TileMap.screenToTile(x <span class="classifier-delimiter">:</span> <span class="classifier">number, y</span> <span class="classifier-delimiter">:</span> <span class="classifier">number)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></span></dt>
<dd>Converts the given position from screen to tile coordinates.</dd>
</dl>
<dl class="docutils" id="script-map-screentotile2">
<dt>TileMap.screenToTile(position <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></span></dt>
<dd>Converts the given position from screen to tile coordinates.</dd>
</dl>
<dl class="docutils" id="script-map-tiletoscreen">
<dt>TileMap.tileToScreen(x <span class="classifier-delimiter">:</span> <span class="classifier">number, y</span> <span class="classifier-delimiter">:</span> <span class="classifier">number)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></span></dt>
<dd>Converts the given position from tile to screen coordinates.</dd>
</dl>
<dl class="docutils" id="script-map-tiletoscreen2">
<dt>TileMap.tileToScreen(position <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></span></dt>
<dd>Converts the given position from tile to screen coordinates.</dd>
</dl>
<dl class="docutils" id="script-map-screentopixel">
<dt>TileMap.screenToPixel(x <span class="classifier-delimiter">:</span> <span class="classifier">number, y</span> <span class="classifier-delimiter">:</span> <span class="classifier">number)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></span></dt>
<dd>Converts the given position from screen to pixel coordinates.</dd>
</dl>
<dl class="docutils" id="script-map-screentopixel2">
<dt>TileMap.screenToPixel(position <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></span></dt>
<dd>Converts the given position from screen to pixel coordinates.</dd>
</dl>
<dl class="docutils" id="script-map-pixeltoscreen">
<dt>TileMap.pixelToScreen(x <span class="classifier-delimiter">:</span> <span class="classifier">number, y</span> <span class="classifier-delimiter">:</span> <span class="classifier">number)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></span></dt>
<dd>Converts the given position from pixel to screen coordinates.</dd>
</dl>
<dl class="docutils" id="script-map-pixeltoscreen2">
<dt>TileMap.pixelToScreen(position <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></span></dt>
<dd>Converts the given position from pixel to screen coordinates.</dd>
</dl>
<dl class="docutils" id="script-map-pixeltotile">
<dt>TileMap.pixelToTile(x <span class="classifier-delimiter">:</span> <span class="classifier">number, y</span> <span class="classifier-delimiter">:</span> <span class="classifier">number)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></span></dt>
<dd>Converts the given position from pixel to tile coordinates.</dd>
</dl>
<dl class="docutils" id="script-map-pixeltotile2">
<dt>TileMap.pixelToTile(position <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></span></dt>
<dd>Converts the given position from pixel to tile coordinates.</dd>
</dl>
<dl class="docutils" id="script-map-tiletopixel">
<dt>TileMap.tileToPixel(x <span class="classifier-delimiter">:</span> <span class="classifier">number, y</span> <span class="classifier-delimiter">:</span> <span class="classifier">number)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></span></dt>
<dd>Converts the given position from tile to pixel coordinates.</dd>
</dl>
<dl class="docutils" id="script-map-tiletopixel2">
<dt>TileMap.tileToPixel(position <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a>)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></span></dt>
<dd>Converts the given position from tile to pixel coordinates.</dd>
</dl>
</div>
</div>
<div class="section" id="tileset">
<span id="script-tileset"></span><h4>Tileset<a class="headerlink" href="#tileset" title="Permalink to this headline">¶</a></h4>
<p>Inherits <a class="reference internal" href="#script-asset"><span class="std std-ref">Asset</span></a>.</p>
<div class="section" id="id35">
<h5>Properties<a class="headerlink" href="#id35" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>name</strong> : string</td>
<td>Name of the tileset.</td>
</tr>
<tr class="row-even"><td><strong>image</strong> : string</td>
<td>The file name of the image used by this tileset. Empty in case of image collection tilesets.</td>
</tr>
<tr class="row-odd"><td><strong>tiles</strong> : [<a class="reference internal" href="#script-tile"><span class="std std-ref">Tile</span></a>] <em>[read‑only]</em></td>
<td>Array of all tiles in this tileset. Note that the index of a tile in this array does not always match with its ID.</td>
</tr>
<tr class="row-even"><td><strong>terrains</strong> : [<a class="reference internal" href="#script-terrain"><span class="std std-ref">Terrain</span></a>] <em>[read‑only]</em></td>
<td>Array of all terrains in this tileset.</td>
</tr>
<tr class="row-odd"><td><strong>tileCount</strong> : int</td>
<td>The number of tiles in this tileset.</td>
</tr>
<tr class="row-even"><td><strong>nextTileId</strong> : int</td>
<td>The ID of the next tile that would be added to this tileset. All existing tiles have IDs that are lower than this ID.</td>
</tr>
<tr class="row-odd"><td><strong>tileWidth</strong> : int</td>
<td>Tile width for tiles in this tileset in pixels.</td>
</tr>
<tr class="row-even"><td><strong>tileHeight</strong> : int</td>
<td>Tile Height for tiles in this tileset in pixels.</td>
</tr>
<tr class="row-odd"><td><strong>tileSize</strong> : <a class="reference internal" href="#script-size"><span class="std std-ref">size</span></a></td>
<td>Tile size for tiles in this tileset in pixels.</td>
</tr>
<tr class="row-even"><td><strong>imageWidth</strong> : int <em>[read‑only]</em></td>
<td>Width of the tileset image in pixels.</td>
</tr>
<tr class="row-odd"><td><strong>imageHeight</strong> : int <em>[read‑only]</em></td>
<td>Height of the tileset image in pixels.</td>
</tr>
<tr class="row-even"><td><strong>imageSize</strong> : <a class="reference internal" href="#script-size"><span class="std std-ref">size</span></a> <em>[read‑only]</em></td>
<td>Size of the tileset image in pixels.</td>
</tr>
<tr class="row-odd"><td><strong>tileSpacing</strong> : int <em>[read‑only]</em></td>
<td>Spacing between tiles in this tileset in pixels.</td>
</tr>
<tr class="row-even"><td><strong>margin</strong> : int <em>[read‑only]</em></td>
<td>Margin around the tileset in pixels (only used at the top and left sides of the tileset image).</td>
</tr>
<tr class="row-odd"><td><strong>objectAlignment</strong> : <a class="reference internal" href="#script-tileset-alignment"><span class="std std-ref">Alignment</span></a></td>
<td>The alignment to use for tile objects (when <code class="docutils literal notranslate"><span class="pre">Unspecified</span></code>, uses <code class="docutils literal notranslate"><span class="pre">Bottom</span></code> alignment on isometric maps and <code class="docutils literal notranslate"><span class="pre">BottomLeft</span></code> alignment for all other maps).</td>
</tr>
<tr class="row-even"><td><strong>tileOffset</strong> : <a class="reference internal" href="#script-point"><span class="std std-ref">point</span></a></td>
<td>Offset in pixels that is applied when tiles from this tileset are rendered.</td>
</tr>
<tr class="row-odd"><td><strong>orientation</strong> : <a class="reference internal" href="#script-tileset-orientation"><span class="std std-ref">Orientation</span></a></td>
<td>The orientation of this tileset (used when rendering overlays and in the tile collision editor).</td>
</tr>
<tr class="row-even"><td><strong>backgroundColor</strong> : color</td>
<td>Background color for this tileset in the <em>Tilesets</em> view.</td>
</tr>
<tr class="row-odd"><td><strong>isCollection</strong> : bool <em>[read‑only]</em></td>
<td>Whether this tileset is a collection of images (same as checking whether <code class="docutils literal notranslate"><span class="pre">image</span></code> is an empty string).</td>
</tr>
<tr class="row-even"><td><strong>selectedTiles</strong> : [<a class="reference internal" href="#script-tile"><span class="std std-ref">Tile</span></a>]</td>
<td>Selected tiles (in the tileset editor).</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils" id="script-tileset-alignment">
<colgroup>
<col width="100%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Tileset.Alignment</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Tileset.Unspecified</td>
</tr>
<tr class="row-odd"><td>Tileset.TopLeft</td>
</tr>
<tr class="row-even"><td>Tileset.Top</td>
</tr>
<tr class="row-odd"><td>Tileset.TopRight</td>
</tr>
<tr class="row-even"><td>Tileset.Left</td>
</tr>
<tr class="row-odd"><td>Tileset.Center</td>
</tr>
<tr class="row-even"><td>Tileset.Right</td>
</tr>
<tr class="row-odd"><td>Tileset.BottomLeft</td>
</tr>
<tr class="row-even"><td>Tileset.Bottom</td>
</tr>
<tr class="row-odd"><td>Tileset.BottomRight</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils" id="script-tileset-orientation">
<colgroup>
<col width="100%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Tileset.Orientation</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Tileset.Orthogonal</td>
</tr>
<tr class="row-odd"><td>Tileset.Isometric</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id36">
<h5>Functions<a class="headerlink" href="#id36" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>new Tileset([name <span class="classifier-delimiter">:</span> <span class="classifier">string])</span></dt>
<dd>Constructs a new tileset.</dd>
<dt>Tileset.tile(id <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tile"><span class="std std-ref">Tile</span></a></span></dt>
<dd><p class="first">Returns a reference to the tile with the given ID. Raises an error if no
such tile exists. When the tile gets removed from the tileset, the
reference changes to a standalone copy of the tile.</p>
<p class="last">Note that the tiles in a tileset are only guaranteed to have consecutive
IDs for tileset-image based tilesets. For image collection tilesets there
will be gaps when tiles have been removed from the tileset.</p>
</dd>
<dt>Tileset.setTileSize(width <span class="classifier-delimiter">:</span> <span class="classifier">int, height</span> <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Sets the tile size for this tileset. If an image has been specified as well,
the tileset will be (re)loaded. Can’t be used on image collection tilesets.</dd>
<dt>Tileset.addTile() <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tile"><span class="std std-ref">Tile</span></a></span></dt>
<dd>Adds a new tile to this tileset and returns it. Only works for image collection tilesets.</dd>
<dt>Tileset.removeTiles(tiles <span class="classifier-delimiter">:</span> <span class="classifier">[<a class="reference internal" href="#script-tile"><span class="std std-ref">Tile</span></a>])</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Removes the given tiles from this tileset. Only works for image collection tilesets.</dd>
</dl>
</div>
</div>
<div class="section" id="tileseteditor">
<span id="script-tileseteditor"></span><h4>TilesetEditor<a class="headerlink" href="#tileseteditor" title="Permalink to this headline">¶</a></h4>
<div class="section" id="id37">
<h5>Properties<a class="headerlink" href="#id37" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>collisionEditor</strong> : <a class="reference internal" href="#script-tilecollisioneditor"><span class="std std-ref">TileCollisionEditor</span></a></td>
<td>Access the collision editor within the tileset editor.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="tilesetformat">
<span id="script-tilesetformatwrapper"></span><h4>TilesetFormat<a class="headerlink" href="#tilesetformat" title="Permalink to this headline">¶</a></h4>
<p>This is an object that can read or write tileset files. (Since 1.4)</p>
<p>Inherits <a class="reference internal" href="#script-fileformat"><span class="std std-ref">FileFormat</span></a>.</p>
<div class="section" id="id38">
<h5>Functions<a class="headerlink" href="#id38" title="Permalink to this headline">¶</a></h5>
<dl class="docutils">
<dt>TilesetFormat.read(fileName <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a></span></dt>
<dd>Read the given file as a tileset. This function will throw an error if reading
is not supported.</dd>
<dt>TilesetFormat.write(tileset <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a>, fileName</span> <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Write the given tileset to a file. This function will throw an error if writing
is not supported. If there is an error writing the file, it will return a
description of the error; otherwise, it will return “”.</dd>
</dl>
</div>
</div>
<div class="section" id="tilesetsview">
<span id="script-tilesetsview"></span><h4>TilesetsView<a class="headerlink" href="#tilesetsview" title="Permalink to this headline">¶</a></h4>
<div class="section" id="id39">
<h5>Properties<a class="headerlink" href="#id39" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>currentTileset</strong> : <a class="reference internal" href="#script-tileset"><span class="std std-ref">Tileset</span></a></td>
<td>Access or change the currently displayed tileset.</td>
</tr>
<tr class="row-even"><td><strong>selectedTiles</strong> : [<a class="reference internal" href="#script-tile"><span class="std std-ref">Tile</span></a>]</td>
<td>A list of the tiles that are selected in the current tileset.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="basic-types">
<span id="script-basic-types"></span><h4>Basic Types<a class="headerlink" href="#basic-types" title="Permalink to this headline">¶</a></h4>
<p>Some types are provided by the Qt Scripting Engine and others are added based
on the needs of the data types above. In the following the most important
ones are documented.</p>
<div class="section" id="alignment">
<span id="script-alignment"></span><h5>Alignment<a class="headerlink" href="#alignment" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Qt.Alignment</th>
<th class="head">&#160;</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Qt.AlignLeft</td>
<td>0x0001</td>
</tr>
<tr class="row-odd"><td>Qt.AlignRight</td>
<td>0x0002</td>
</tr>
<tr class="row-even"><td>Qt.AlignHCenter</td>
<td>0x0004</td>
</tr>
<tr class="row-odd"><td>Qt.AlignJustify</td>
<td>0x0008</td>
</tr>
<tr class="row-even"><td>Qt.AlignTop</td>
<td>0x0020</td>
</tr>
<tr class="row-odd"><td>Qt.AlignBottom</td>
<td>0x0040</td>
</tr>
<tr class="row-even"><td>Qt.AlignVCenter</td>
<td>0x0080</td>
</tr>
<tr class="row-odd"><td>Qt.AlignCenter</td>
<td>Qt.AlignVCenter | Qt.AlignHCenter</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="cell">
<span id="script-cell"></span><h5>cell<a class="headerlink" href="#cell" title="Permalink to this headline">¶</a></h5>
<p>A cell on a <a class="reference internal" href="#script-tilelayer"><span class="std std-ref">TileLayer</span></a>.</p>
<p><strong>Properties</strong></p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>tileId</strong> : int</td>
<td>The local tile ID of the tile, or -1 if the cell is empty.</td>
</tr>
<tr class="row-even"><td><strong>empty</strong> : bool</td>
<td>Whether the cell is empty.</td>
</tr>
<tr class="row-odd"><td><strong>flippedHorizontally</strong> : bool</td>
<td>Whether the tile is flipped horizontally.</td>
</tr>
<tr class="row-even"><td><strong>flippedVertically</strong> : bool</td>
<td>Whether the tile is flipped vertically.</td>
</tr>
<tr class="row-odd"><td><strong>flippedAntiDiagonally</strong> : bool</td>
<td>Whether the tile is flipped anti-diagonally.</td>
</tr>
<tr class="row-even"><td><strong>rotatedHexagonal120</strong> : bool</td>
<td>Whether the tile is rotated by 120 degrees (for hexagonal maps, the anti-diagonal flip is interpreted as a 60-degree rotation).</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="filepath">
<span id="script-filepath"></span><h5>FilePath<a class="headerlink" href="#filepath" title="Permalink to this headline">¶</a></h5>
<p>Used as the value for custom ‘file’ properties. Can be created with
<a class="reference internal" href="#script-tiled-filepath"><span class="std std-ref">tiled.filePath</span></a>.</p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="25%" />
<col width="75%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>url</strong> : url</td>
<td>The URL of the file.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="font">
<span id="script-font"></span><h5>Font<a class="headerlink" href="#font" title="Permalink to this headline">¶</a></h5>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>family</strong> : string</td>
<td>The font family.</td>
</tr>
<tr class="row-even"><td><strong>pixelSize</strong> : int</td>
<td>Font size in pixels.</td>
</tr>
<tr class="row-odd"><td><strong>bold</strong> : bool</td>
<td>Whether the font is bold.</td>
</tr>
<tr class="row-even"><td><strong>italic</strong> : bool</td>
<td>Whether the font is italic.</td>
</tr>
<tr class="row-odd"><td><strong>underline</strong> : bool</td>
<td>Whether the text is underlined.</td>
</tr>
<tr class="row-even"><td><strong>strikeOut</strong> : bool</td>
<td>Whether the text is striked through.</td>
</tr>
<tr class="row-odd"><td><strong>kerning</strong> : bool</td>
<td>Whether to use kerning when rendering the text.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="frames">
<span id="script-frames"></span><h5>Frames<a class="headerlink" href="#frames" title="Permalink to this headline">¶</a></h5>
<p>An array of frames, which are objects with the following properties:</p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>tileId</strong> : int</td>
<td>The local tile ID used to represent the frame.</td>
</tr>
<tr class="row-even"><td><strong>duration</strong> : int</td>
<td>Duration of the frame in milliseconds.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="objectref">
<span id="script-objectref"></span><h5>ObjectRef<a class="headerlink" href="#objectref" title="Permalink to this headline">¶</a></h5>
<p>The value of a property of type ‘object’, which refers to a
<a class="reference internal" href="#script-mapobject"><span class="std std-ref">MapObject</span></a> by its ID. Generally only used as a fallback when an
object property cannot be resolved to an actual object. Can be created with
<a class="reference internal" href="#script-tiled-objectref"><span class="std std-ref">tiled.objectRef</span></a>.</p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="25%" />
<col width="75%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>id</strong> : int</td>
<td>The ID of the referenced object.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="point">
<span id="script-point"></span><h5>point<a class="headerlink" href="#point" title="Permalink to this headline">¶</a></h5>
<p><code class="docutils literal notranslate"><span class="pre">Qt.point(x,</span> <span class="pre">y)</span></code> can be used to create a point object.</p>
<p><strong>Properties</strong></p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>x</strong> : number</td>
<td>X coordinate of the point.</td>
</tr>
<tr class="row-even"><td><strong>y</strong> : number</td>
<td>Y coordinate of the point.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="polygon">
<span id="script-polygon"></span><h5>Polygon<a class="headerlink" href="#polygon" title="Permalink to this headline">¶</a></h5>
<p>A polygon is not strictly a custom type. It is an array of objects that each
have an <code class="docutils literal notranslate"><span class="pre">x</span></code> and <code class="docutils literal notranslate"><span class="pre">y</span></code> property, representing the points of the polygon.</p>
<p>To modify the polygon of a <a class="reference internal" href="#script-mapobject"><span class="std std-ref">MapObject</span></a>, change or set up the
polygon array and then assign it to the object.</p>
</div>
<div class="section" id="rect">
<span id="script-rect"></span><h5>rect<a class="headerlink" href="#rect" title="Permalink to this headline">¶</a></h5>
<p><code class="docutils literal notranslate"><span class="pre">Qt.rect(x,</span> <span class="pre">y,</span> <span class="pre">width,</span> <span class="pre">height)</span></code> can be used to create a rectangle.</p>
<p><strong>Properties</strong></p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>x</strong> : int</td>
<td>X coordinate of the rectangle.</td>
</tr>
<tr class="row-even"><td><strong>y</strong> : int</td>
<td>Y coordinate of the rectangle.</td>
</tr>
<tr class="row-odd"><td><strong>width</strong> : int</td>
<td>Width of the rectangle.</td>
</tr>
<tr class="row-even"><td><strong>height</strong> : int</td>
<td>Height of the rectangle.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="region">
<span id="script-region"></span><h5>region<a class="headerlink" href="#region" title="Permalink to this headline">¶</a></h5>
<p><strong>Properties</strong></p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>boundingRect</strong> : <a class="reference internal" href="#script-rect"><span class="std std-ref">rect</span></a> <em>[read‑only]</em></td>
<td>Bounding rectangle of the region.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="size">
<span id="script-size"></span><h5>size<a class="headerlink" href="#size" title="Permalink to this headline">¶</a></h5>
<p><code class="docutils literal notranslate"><span class="pre">Qt.size(width,</span> <span class="pre">height)</span></code> can be used to create a size object.</p>
<p><strong>Properties</strong></p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>width</strong> : number</td>
<td>Width.</td>
</tr>
<tr class="row-even"><td><strong>height</strong> : number</td>
<td>Height.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="terrains">
<span id="script-tileterrains"></span><h5>Terrains<a class="headerlink" href="#terrains" title="Permalink to this headline">¶</a></h5>
<p>An object specifying the terrain for each corner of a tile:</p>
<table border="1" class="docutils">
<colgroup>
<col width="100%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>topLeft</strong> : <a class="reference internal" href="#script-terrain"><span class="std std-ref">Terrain</span></a></td>
</tr>
<tr class="row-even"><td><strong>topRight</strong> : <a class="reference internal" href="#script-terrain"><span class="std std-ref">Terrain</span></a></td>
</tr>
<tr class="row-odd"><td><strong>bottomLeft</strong> : <a class="reference internal" href="#script-terrain"><span class="std std-ref">Terrain</span></a></td>
</tr>
<tr class="row-even"><td><strong>bottomRight</strong> : <a class="reference internal" href="#script-terrain"><span class="std std-ref">Terrain</span></a></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="textfile">
<span id="script-textfile"></span><h5>TextFile<a class="headerlink" href="#textfile" title="Permalink to this headline">¶</a></h5>
<p>The TextFile object is used to read and write files in text mode.</p>
<p>When using <code class="docutils literal notranslate"><span class="pre">TextFile.WriteOnly</span></code>, you need to call <code class="docutils literal notranslate"><span class="pre">commit()</span></code> when you’re
done writing otherwise the operation will be aborted without effect.</p>
<p><strong>Properties</strong></p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>filePath</strong> : string <em>[read‑only]</em></td>
<td>The path of the file.</td>
</tr>
<tr class="row-even"><td><strong>atEof</strong> : bool <em>[read‑only]</em></td>
<td>True if no more data can be read.</td>
</tr>
<tr class="row-odd"><td><strong>codec</strong> : string</td>
<td>The text codec.</td>
</tr>
</tbody>
</table>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">TextFile.OpenMode</th>
<th class="head">&#160;</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>TextFile.ReadOnly</td>
<td>0x0001</td>
</tr>
<tr class="row-odd"><td>TextFile.WriteOnly</td>
<td>0x0002</td>
</tr>
<tr class="row-even"><td>TextFile.ReadWrite</td>
<td>TextFile.ReadOnly | TextFile.WriteOnly</td>
</tr>
<tr class="row-odd"><td>TextFile.Append</td>
<td>&#160;</td>
</tr>
</tbody>
</table>
<p><strong>Functions</strong></p>
<dl class="docutils">
<dt>new TextFile(fileName <span class="classifier-delimiter">:</span> <span class="classifier">string [, mode</span> <span class="classifier-delimiter">:</span> <span class="classifier">OpenMode = ReadOnly])</span></dt>
<dd>Opens a text file in the given mode.</dd>
<dt>TextFile.readLine() <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Reads one line of text from the file and returns it. The returned string
does not contain the newline characters.</dd>
<dt>TextFile.readAll() <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
<dd>Reads all data from the file and returns it.</dd>
<dt>TextFile.truncate() <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Truncates the file, that is, gives it the size of zero, removing all
content.</dd>
<dt>TextFile.write(text <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Writes a string to the file.</dd>
<dt>TextFile.writeLine(text <span class="classifier-delimiter">:</span> <span class="classifier">string)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Writes a string to the file and appends a newline character.</dd>
<dt>TextFile.commit() <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Commits all written text to disk and closes the file. Should be called when
writing to files in WriteOnly mode. Failing to call this function will
result in cancelling the operation, unless safe writing to files is disabled.</dd>
<dt>TextFile.close() <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Closes the file. It is recommended to always call this function as soon as
you are finished with the file.</dd>
</dl>
</div>
<div class="section" id="binaryfile">
<span id="script-binaryfile"></span><h5>BinaryFile<a class="headerlink" href="#binaryfile" title="Permalink to this headline">¶</a></h5>
<p>The BinaryFile object is used to read and write files in binary mode.</p>
<p>When using <code class="docutils literal notranslate"><span class="pre">BinaryFile.WriteOnly</span></code>, you need to call <code class="docutils literal notranslate"><span class="pre">commit()</span></code> when you’re
done writing otherwise the operation will be aborted without effect.</p>
<p><strong>Properties</strong></p>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><strong>filePath</strong> : string <em>[read‑only]</em></td>
<td>The path of the file.</td>
</tr>
<tr class="row-even"><td><strong>atEof</strong> : bool <em>[read‑only]</em></td>
<td>True if no more data can be read.</td>
</tr>
<tr class="row-odd"><td><strong>size</strong> : number</td>
<td>The size of the file (in bytes).</td>
</tr>
<tr class="row-even"><td><strong>pos</strong> : number</td>
<td>The position that data is written to or read from.</td>
</tr>
</tbody>
</table>
<table border="1" class="colwidths-given docutils">
<colgroup>
<col width="33%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">BinaryFile.OpenMode</th>
<th class="head">&#160;</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>BinaryFile.ReadOnly</td>
<td>0x0001</td>
</tr>
<tr class="row-odd"><td>BinaryFile.WriteOnly</td>
<td>0x0002</td>
</tr>
<tr class="row-even"><td>BinaryFile.ReadWrite</td>
<td>BinaryFile.ReadOnly | BinaryFile.WriteOnly</td>
</tr>
</tbody>
</table>
<p><strong>Functions</strong></p>
<dl class="docutils">
<dt>new BinaryFile(filePath <span class="classifier-delimiter">:</span> <span class="classifier">string [, mode</span> <span class="classifier-delimiter">:</span> <span class="classifier">OpenMode = ReadOnly])</span></dt>
<dd>Opens a binary file in the given mode.</dd>
<dt>BinaryFile.resize(size <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Sets the file size (in bytes). If size is larger than the file currently is,
the new bytes will be set to 0; if size is smaller, the file is truncated.</dd>
<dt>BinaryFile.seek(pos <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Sets the current position to <em>pos</em>.</dd>
<dt>BinaryFile.read(size <span class="classifier-delimiter">:</span> <span class="classifier">int)</span> <span class="classifier-delimiter">:</span> <span class="classifier">ArrayBuffer</span></dt>
<dd>Reads at most <em>size</em> bytes of data from the file and returns it as an
ArrayBuffer.</dd>
<dt>BinaryFile.readAll() <span class="classifier-delimiter">:</span> <span class="classifier">ArrayBuffer</span></dt>
<dd>Reads all data from the file and returns it as an ArrayBuffer.</dd>
<dt>BinaryFile.write(data <span class="classifier-delimiter">:</span> <span class="classifier">ArrayBuffer)</span> <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Writes <em>data</em> into the file at the current position.</dd>
<dt>BinaryFile.commit() <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Commits all written data to disk and closes the file. Should be called when
writing to files in WriteOnly mode. Failing to call this function will
result in cancelling the operation, unless safe writing to files is
disabled.</dd>
<dt>BinaryFile.close() <span class="classifier-delimiter">:</span> <span class="classifier">void</span></dt>
<dd>Closes the file. It is recommended to always call this function as soon as
you are finished with the file.</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
</div>


           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2019, Tiled Documentation Writers
      
        <span class="commit">
          Revision <code>7f62c3d8</code>.
        </span>
      

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  

  <div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
    <span class="rst-current-version" data-toggle="rst-current-version">
      <span class="fa fa-book"> Read the Docs</span>
      v: latest
      <span class="fa fa-caret-down"></span>
    </span>
    <div class="rst-other-versions">
      <dl>
        <dt>Versions</dt>
        
          <dd><a href="/en/latest/">latest</a></dd>
        
          <dd><a href="/en/stable/">stable</a></dd>
        
      </dl>
      <dl>
        <dt>Downloads</dt>
        
          <dd><a href="//doc.mapeditor.org/_/downloads/en/latest/pdf/">pdf</a></dd>
        
          <dd><a href="//doc.mapeditor.org/_/downloads/en/latest/htmlzip/">html</a></dd>
        
      </dl>
      <dl>
        <dt>On Read the Docs</dt>
          <dd>
            <a href="//readthedocs.org/projects/tiled/?fromdocs=tiled">Project Home</a>
          </dd>
          <dd>
            <a href="//readthedocs.org/builds/tiled/?fromdocs=tiled">Builds</a>
          </dd>
      </dl>
      <hr/>
      Free document hosting provided by <a href="http://www.readthedocs.org">Read the Docs</a>.

    </div>
  </div>



  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  

  <!-- OVERRIDE: Added for Algolia powered search popup -->
	<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js">
	</script><script type="text/javascript">
	docsearch({
	  apiKey: '3535ea3f554af15b8796f9f9c3339da7',
	  indexName: 'mapeditor',
	  inputSelector: '#rtd-search-form > input:first-child',
	  algoliaOptions: { 'facetFilters': ["version:latest"] },
	  debug: false // Set debug to true if you want to inspect the dropdown
	});
	</script> 

</body>
</html>